Version: 1.1
Type: Sample Code (HOWTO)
Category: Other
License: GNU General Public License
Description: Check if a program is running and print up or down based on the pidof command.
This should be 100% accurate.
This is the normal version and just displays up or down in plain tekst. <?php $return_var = exec('pidof $app_name'); if ($return_var>0) { echo "Up"; } if ($return_var==0) { echo "DOWN"; } ?> Fancy version <?php $return_var = exec('pidof $app_name'); if ($return_var>0) { echo "<b><font color=blue>Up</font></b>"; } if ($return_var==0) { echo "<b><font color=red>DOWN</font></b>"; } ?> Fancy version with pid showing when the app is up <?php $return_var = exec('pidof $app_name'); if ($return_var>0) { echo "<b><font color=blue>Up</font></b>, with pid: "; echo $return_var; } if ($return_var==0) { echo "<b><font color=red>DOWN</font></b>"; } ?>