If the service runs as a daemon, you can see if it is running with the "pidof" command. If it returns nothing, the service is not running. Otherwise, it gives you the pid(s) of the process(es) running.
For example:
pidof httpd
15973 15938 5291 26219 26212 18519 14400 24442 24441 24317 21207 17957 17955 17954 17953 7161 18977 18797
That is the master process and all of it's children running.
/sbin/pidof asgasg
That returns nothing, naturally, because asgasg doesn't even exist, much less is running.
In bash, you can do something like this in a script:
Code:
#!/bin/bash
if [ -z "$(/sbin/pidof httpd)" ]; then
echo "httpd is not running"
else
echo "httpd is running"
fi
Hope this helps.