Ubuntu – List all services starting at boot

14.04bootmonitoringservices

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.

Best Answer

All services start on startup:

initctl list

List of all services which exist in system:

service --status-all
Related Question