'waynsley@gmail.com' ); function index() { global $monitor_config, $errors; check_httpd(); if(!empty($errors)) { mail($monitor_config['sysadmin'], 'Server Monitor Errors', var_export($errors, true)); } } /** * e.g. /usr/local/bin/php /home/waynsley/public_html/platform/monitor.php > /dev/null 2>> monitor.log.error * @return boolean */ function check_httpd() { global $errors; $cmd = 'ps -U root | grep -v grep | grep -c httpd'; $running = exec($cmd); if($running) return true; else { $errors[] = 'Apache not running'; //exec('/usr/local/apache/bin/apachectl start'); exec('service httpd start'); } } index();