@lokesh-suthar,
create a script:
sudo nano /opt/relaunch-stopped-services.sh
#!/bin/bash
service YOUR_SERVICE_NAME_HERE status | grep 'active (running)' > /dev/null 2>&1
if [ $? != 0 ]
then
sudo service YOUR_SERVICE_NAME_HERE restart > /dev/null
fi
Then,
make it executable: sudo chmod +x /opt/relaunch-stopped-services.sh
Next,
You need to edit your root crontab list sudo crontab -e
and not your user profile crontab.
*/5 * * * * /opt/relaunch-stopped-services.sh > /dev/null 2>
This script will run every 5 minutes.
Full details: https://zeropointdevelopment.com/how-to-use-a-bash-script-to-restart-linux-server-services/
Cordially,
Ronnie Wong
Edutainer Manager, ITProTV
*if the post above has answered the question, please mark as solved.
**All "answers" and responses are offered "as is" and my opinion. There is no implied service, support, or guarantee by ITProTV.