List all services starting at boot
I'm looking for a way to get a list of all the services (/etc/init.d or upstart or systemd), which are supposed to be starting (or having been started at) boot.
How do you get a list of all starting services? — I know that question, and it suggests to use service --status-all
.
But that doesn't show me, which services are SUPPOSED TO BE RUNNING. It calls all the init scripts with "status
" argument. This is a list of all the services that could be running.
But I would like to know, if a service, that had been started at boot is still running.
Example…
I have webfs installed. But I do not want it to be running at boot. Thus I disabled it: sudo update-rc.d webfs disable
. And I also have samba installed and it should be running at boot. But it is stopped (for whatever reason). sudo service --status-all
doesn't help me here:
$ sudo service --status-all 2>/dev/null | grep -E 'samba$|webfs'
[ - ] samba
[ - ] webfs
Both are off but I get no clue, that one (samba) is supposed to be on.
So…
How could I get a list of all services which are starting at boot? And, as an extension, is there an easy way to get the "status" of these services (if not, I'll simply loop over this list and run "service $service status", or something like this).
Thanks, Alexander
Edit 2015-05-04: I'm on Ubuntu 14.04.
The main focus of this question is the following:
But I would like to know, if a service, that had been started at boot is still running.
Because of this, initctl list
doesn't help much. It doesn't really take into consideration the services started by /etc/init.d
scripts (compared to upstart scripts in /etc/init
).
Also a listing of /etc/rc?.d/S*
doesn't help. It would generate a list of services, which might have been started in a given runlevel. It doesn't show me, if a service, that should've been started, is still running.
Basically, I'm looking for something like svcs -x
from Solaris for Ubuntu. With svcs -x
, I'd have output if a service, which was started, isn't running anymore. This, I'd need for Ubuntu as well.
Reason: I'd like to have a (more or less...) generic check for our Icinga/Nagios monitoring system, which would alert me, if a service isn't running anymore, which should be running. As we've got many different servers for many different customers, it doesn't really scale to define a list of "important" services.
Solution 1:
All services start on startup:
initctl list
List of all services which exist in system:
service --status-all
Solution 2:
List all services and respective runlevel status - chkconfig style:
# sysv-rc-conf --list
acpid 2:on 3:on 4:on 5:on
apache-htcac 0:off 1:off 2:off 3:off 4:off 5:off 6:off
apache2 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Interactive text based edit of all listed:
# sysv-rc-conf
l SysV Runlevel Config -: stop service =/+: start service h: help q: quit qk
x
x service 1 2 3 4 5 0 6 S
x ----------------------------------------------------------------------------
x acpid [ ] [X] [X] [X] [X] [ ] [ ] [ ]
x apache-ht$ [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]
x apache2 [ ] [X] [X] [X] [X] [ ] [ ] [ ]
x
x Use the arrow keys or mouse to move around. ^n: next pg ^p: prev pg
x space: toggle service on / off
Might have to install it if not there:
apt install sysv-rc-conf