Autostart: Difference between revisions
Created page with "When your machine turns on or reboots, you want certain things to happen automatically. If the 'machine' is a web server hosting websites defined by Apache and also a dat..." |
adds more Ubuntu reference |
||
| Line 1: | Line 1: | ||
When your machine turns on or reboots, you want certain things to happen automatically. If the 'machine' is a web server hosting websites defined by [[Apache]] and also a database server running [[MySQL]], then naturally you would want Apache and MySQL to start automatically. In SysV-style systems that still use <code>init</code> and the rc.d run levels, you can use either <code>chkconfig</code><ref>http://linuxcommand.org/man_pages/chkconfig8.html</ref> (RedHat and derivatives) or <code>sysv-rc-conf</code> for Debian variants to make that permanent. | When your machine turns on or reboots, you want certain things to happen automatically. If the 'machine' is a web server hosting websites defined by [[Apache]] and also a database server running [[MySQL]], then naturally you would want Apache and MySQL to start automatically. In SysV-style systems that still use <code>init</code> and the rc.d run levels, you can use either <code>chkconfig</code><ref>http://linuxcommand.org/man_pages/chkconfig8.html</ref> (RedHat and derivatives) or <code>sysv-rc-conf</code> or <code>update-rc.d</code><ref>http://manpages.ubuntu.com/manpages/precise/man8/update-rc.d.8.html</ref>for Debian variants to make that permanent. The old SysV style init has now largely been replaced by <code>systemd</code>, so this article is just to guide you through some of the equivalents across multiple ways of doing init. | ||
=== List services === | === List services === | ||
So what are the services controlled by | So what are the services controlled by init<ref>http://manpages.ubuntu.com/manpages/trusty/man5/init.5.html</ref><ref>http://manpages.ubuntu.com/manpages/trusty/man8/init.8.html</ref> scripts? | ||
<source lang="bash"> | <source lang="bash"> | ||
# the easy way | # the easy way (if somewhat non-specific) | ||
ls -l /etc/rc.d/init.d/ | ls -l /etc/rc.d/init.d/ | ||
# using chkconfig | # On Ubuntu 14.04 you'll have the 'service' command | ||
# service --status-all runs all init scripts, in alphabetical order, with the status command. This option only calls status for sysvinit jobs | |||
service --status-all | |||
# upstart jobs can be queried in a similar manner with initctl list | |||
initctl list | |||
# on older Ubuntu like 14.04, you probably also have update-rc.d, but that doesn't have a 'list' command | |||
# You could 'manually' search all the init scripts for the right runlevel | |||
grep -i 'runlevel' /etc/init/*| awk '!/#/ && /start on/ && /2/ {gsub("/"," "); print $0 }' | cut -d ' ' -f4- | |||
# or | |||
grep -i 'runlevel' /etc/init/* | awk '/start on/ && /2/ {gsub("/"," "); gsub(":", " ");gsub(".conf"," "); print $3 }' | |||
# the RedHat way (using chkconfig) | |||
chkconfig --list | chkconfig --list | ||
# for newer systemd controlled systems | # for newer systemd controlled systems | ||