Thursday, March 9, 2017

Linux Server Service Start if it's automatically stopped.


Create File Name like servicestart and enter below lines in to that and replace the service=apache2 to anyother service name.

# vi servicestart
+++++++++++++++++++++
#!/bin/bash
service=apache2

if (( $(ps -ef | grep -v grep | grep $service | wc -l) > 0 ))
then
echo "$service is running!!!"
else
/etc/init.d/$service start
fi
+++++++++++++++++++++
Save an Close this file.

Put it in to Cron to run at every minute.

# crontab -e
*/1 * * * * /bin/bash /root/servicerestart

1 comment:

  1. JackpotCity Casino: 50 FREE SPINS for all New Players
    JackpotCity Casino 전주 출장안마 is the most exciting, 인천광역 출장샵 original and innovative casino you 용인 출장마사지 can play at. Claim your 100% welcome bonus and access over 5000 other 경산 출장안마 Casino 목포 출장마사지

    ReplyDelete