Skip to main content

need to restart if the service is down

Comments

6 comments

  • karlos.vanger
    You can get better insight here [url=http://superuser.com/questions/683325/linux-to-monitor-a-service-and-restart-if-stopped]shell - Linux : To monitor a Service and restart if stopped? - Super User
    0
  • shufil
    ]You can get better insight here [url=http://superuser.com/questions/683325/linux-to-monitor-a-service-and-restart-if-stopped]shell - Linux : To monitor a Service and restart if stopped? - Super User

    Thanks for reply , I just try this command as per following site #!/bin/bash #service monitoring /bin/netstat -tulpn | awk '{print $4}' | awk -F: '{print $4}' | grep ^3007$ > /dev/null 2>/dev/null a=$(echo $?) if test $a -ne 0 then echo "node.js service down" nohup node test_app.js & > /dev/null 2>/dev/null else sleep 0 fi so its correctly start application and give a massage that is " node.js service down ", so now application is running, then again i run the script so the same massage replicating, its means application runing or down script working same . so can we use same script for if the application is running we no need to get any massage and no need to run nohup node test_app.js &. (restarting command). Plz advice me..
    0
  • cPanelMichael
    ]so now application is running, then again i run the script so the same massage replicating , its means application runing or down script working same .

    Hello :) Could you elaborate further on this statement? For instance, is the application running successfully or is it still failing? Thank you.
    0
  • shufil
    ]Hello :) Could you elaborate further on this statement? For instance, is the application running successfully or is it still failing? Thank you.

    If the application running or down the script output getting same, like if the node.js application running and we are try to run the script, so that time script output should be " its working fine " . no need to try restart or start again, but its application running or down the script try to start or restart application.
    0
  • cPanelMichael
    You may want to consult with a developer or system administrator to assist you with your custom script if it's not accurately detecting if the service is running. Thank you.
    0
  • shufil
    ]You may want to consult with a developer or system administrator to assist you with your custom script if it's not accurately detecting if the service is running. Thank you.

    Michael, This is normal web site, am using bash script for start a service if it down, that service port 3007, but my bash script every time given same result, even service is working bash script will try to restart, that is my problem. also i noted last day i upgrade whm, after this user all crones not working, then i restart crone service and copy all crone jobs from user to root, but i think particular crone not working . 00 3 * * * /bin/sh /path/mysql_backup.sh 00 7 * * * /bin/sh /path/rtm.sh 05 7 * * * /bin/sh /path/rtm2.sh 02 * * * * /bin/sh /path/test.sh If any one have any idea about this plz help me .
    0

Please sign in to leave a comment.