There are two types of services on Ubuntu Linux (Ubuntu version 14). One are upstart based and others based on sysv init. To check if a service us upstart based you can visit the tutorial: Ubuntu – check if a service is upstart based.
Check auto start status of sysv init based service
To see if a service will auto start at boot time on Ubuntu we can use on of the following two approaches:
-
Use update-rc.d to enable service to auto restart with dry-run option
-n
. If we get “already exist” message, that means service will start on boot.## dry-run $ sudo update-rc.d -n nginx defaults System start/stop links for /etc/init.d/nginx already exist.
In case we get “Adding system startup” message, that means service will not auto start on boot. It would not make any change since we are running in dry-run mode. He is how it would look:
## dry-run $ sudo update-rc.d -n nginx defaults Adding system startup for /etc/init.d/nginx ... /etc/rc0.d/K20nginx -> ../init.d/nginx /etc/rc1.d/K20nginx -> ../init.d/nginx /etc/rc6.d/K20nginx -> ../init.d/nginx /etc/rc2.d/S20nginx -> ../init.d/nginx /etc/rc3.d/S20nginx -> ../init.d/nginx /etc/rc4.d/S20nginx -> ../init.d/nginx /etc/rc5.d/S20nginx -> ../init.d/nginx
-
We can also check /etc/rc*.d/ directories to see if a service will autostart on boot. Presence of symlinks will imply that service will auto start on boot.
$ ls /etc/rc*.d/*nginx /etc/rc0.d/K20nginx /etc/rc1.d/K20nginx /etc/rc2.d/S20nginx /etc/rc3.d/S20nginx /etc/rc4.d/S20nginx /etc/rc5.d/S20nginx /etc/rc6.d/K20nginx
Check auto start status of upstart based service
Some services like mysql which are based on upstart has startup job file at /etc/init/mysql.conf. For such scripts, you can view the job config file to find its on boot auto-start status. If you see entry starting with “start on”, it implies that service will auto start on boot at mentioned runlevels. Example entry for mysql:
start on runlevel [2345]