It often happens that database or dns of a server fails and the sites hosted in it stop working. A server reboot or a start of the service brings things to normal. This can be stopped by server hardening as attacks are a prime reason for overloading and crashing of services. Hardening is delat in this article. However, services may stop for internal reasons too. So we will add a cron job that will check for service status and start it if it is crashed due to any reason. List all services and their status systemctl list-unit-files (exit by ctrl+c) Common services APACHE - httpd DATABASE - mariadb or mariadb.service DNS - named or named.service service named status Auto Recovery 1. Create a file named.bash #!/bin/bash service=mariadb if (( $(ps -ef | grep -v grep | grep $service | wc -l) != 2 )) then echo $(ps -ef | grep -v grep | grep $service | wc -l) echo "$service is running!!!" #else #systemctl start named.service fi