Comment 46 for bug 600219

Revision history for this message
Hugo (hugohg34) wrote :

I did this in PHP and run it as root in /etc/crontab

PHP:
<?php
/**
* Comprueba que faxgetty se ejecuta y en caso contrario reinicia el demonio
* Check if faxgetty runs and if not restart the service
*
*/

$proceso='faxgetty'; //process
$busqueda='faxgett'; //find process
$comando="ps -Al -cmd| grep $busqueda"; //command !!!
$fecha=date("d-m-Y h:i");

$resultado=exec($comando); //execute command

### find $busqueda in $resultado ###
if(stripos($resultado,$proceso))
{
  echo "Proceso encontrado - sin acciones"; //OK
}
else
{
  echo "Proceso no encontrado reinicinado server hylafax";
  exec("/etc/init.d/hylafax restart");
}
?>

Edit /etc/crontab and add:

#runfaxgetty .php runs every hour
01 * * * * root php -f /runfaxgetty.php