Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if a particular service is running on Ubuntu

People also ask

How do you check services are running or not?

You can do this by making your own Interface where you declare for example " isServiceRunning() ". You can then bind your Activity to your Service, run the method isServiceRunning(), the Service will check for itself if it is running or not and returns a boolean to your Activity.


I don't have an Ubuntu box, but on Red Hat Linux you can see all running services by running the following command:

service --status-all

On the list the + indicates the service is running, - indicates service is not running, ? indicates the service state cannot be determined.


For Ubuntu (checked with 12.04)

You can get list of all services and select by color one of them with 'grep':

sudo service --status-all | grep postgres

Or you may use another way if you know correct name of service:

sudo service postgresql status

Maybe what you want is the ps command;

ps -ef

will show you all processes running. Then if you have an idea of what you're looking for use grep to filter;

ps -ef | grep postgres

There is a simple way to verify if a service is running

systemctl status service_name

Try PostgreSQL:

systemctl status postgresql