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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With