Show whether a process is either running or not
I use Debian Squeeze and Nginx.
Help would be greatly appreciated.
4 Replies
ps -C <process_name></process_name>
This will show a list of currently running processes. For example, if you want to know if the SSH server is running, you do "ps -C sshd".
Write a PHP script (or a script in any other language that you prefer) to execute this command and count the number of entries.
What I was thinking was being able to show if a process is running or not on a webpage by the words "Online" and "Offline".
I'd like some more replies if possible. Any help would be awesome.
PHP is probably the easiest language to set up with nginx, because nginx doesn't support plain old CGI, Python/Ruby frameworks are overkill for your purpose, and there are tons of tutorials for setting up Debian+nginx with PHP/FastCGI. (Don't bother with compiling FPM, just use php5-cgi and spawn-fcgi packages from the repository.)
Save it as "ps.php" someplace where nginx can serve it. Set up nginx to use PHP if you already haven't done so.
Now, visit
Caution: You probably don't want this script to be accessible to everyone in the world. Although I think I've built in adequate protections from injection attacks, it would be a good idea to hide it where other people won't know.