{"id":223,"date":"2014-01-06T01:31:52","date_gmt":"2014-01-06T01:31:52","guid":{"rendered":"http:\/\/www.linuxmaster.tk\/?p=223"},"modified":"2014-01-06T01:31:52","modified_gmt":"2014-01-06T01:31:52","slug":"shell-script-to-check-a-process-for-every-3-min-start-the-process-if-it-stops","status":"publish","type":"post","link":"https:\/\/linuxmaster.in\/?p=223","title":{"rendered":"Shell script to check a process for every 3 min &#038; start the process if it stops"},"content":{"rendered":"<p>while [ 1 -eq 1 ]<br \/>\ndo<br \/>\ni=0<br \/>\ni=`ps -ef | grep process_to_check | grep -v grep | wc -l`<br \/>\n#echo $i<br \/>\nif [ &#8220;$i&#8221; -lt 1 ]<br \/>\nthen<br \/>\necho &#8220;starting the process&#8221;<br \/>\ncd \/path to the process bin folder\/<br \/>\n.\/start_the_process<br \/>\nfi<br \/>\nsleep 180<br \/>\n# runs for every 3 minute.<br \/>\ndone<\/p>\n<p>##Note: Replace process_to_check with the actual process that you need to check<br \/>\n##Note: &#8220;path to the process bin folder&#8221; should be replaced with the actual path of the process bin folder<br \/>\n##Note: &#8220;start_the_process&#8221; should be replaced with the actually command to start the process from bin folder.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>while [ 1 -eq 1 ] do i=0 i=`ps -ef | grep process_to_check | grep -v grep | wc -l` #echo $i if [ &#8220;$i&#8221; -lt 1 ] then echo &#8220;starting the process&#8221; cd \/path to the process bin folder\/ .\/start_the_process fi sleep 180 # runs for every 3 minute. done ##Note: Replace process_to_check with &hellip; <a href=\"https:\/\/linuxmaster.in\/?p=223\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Shell script to check a process for every 3 min &#038; start the process if it stops&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-223","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/linuxmaster.in\/index.php?rest_route=\/wp\/v2\/posts\/223","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxmaster.in\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxmaster.in\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxmaster.in\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxmaster.in\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=223"}],"version-history":[{"count":2,"href":"https:\/\/linuxmaster.in\/index.php?rest_route=\/wp\/v2\/posts\/223\/revisions"}],"predecessor-version":[{"id":225,"href":"https:\/\/linuxmaster.in\/index.php?rest_route=\/wp\/v2\/posts\/223\/revisions\/225"}],"wp:attachment":[{"href":"https:\/\/linuxmaster.in\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=223"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxmaster.in\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=223"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxmaster.in\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=223"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}