Monitor services (Apache, MySQL, HHVM) using crontab

Want to ensure that your services (Apache, MySQL, HHVM) on your linux instance are running 24*7? Then you can use crontab for that. This job runs every minute to check the status of the service and if it is not running then, it starts the service.

sudo -i
crontab -e

* * * * * service mysql status || service mysql start
* * * * * service apache2 status || service apache2 start
* * * * * service hhvm status || service hhvm start

Ctrl+O Save -> Enter -> Ctrl+X Close

service cron restart