{"id":64,"date":"2008-07-19T10:09:27","date_gmt":"2008-07-19T09:09:27","guid":{"rendered":"http:\/\/www.nooblet.org\/blog\/?p=64"},"modified":"2013-01-10T03:23:02","modified_gmt":"2013-01-10T03:23:02","slug":"checkprocesssh-check-process-restart","status":"publish","type":"post","link":"https:\/\/www.nooblet.org\/blog\/2008\/checkprocesssh-check-process-restart\/","title":{"rendered":"checkprocess.sh &#8211; Check process &#038; restart"},"content":{"rendered":"<p>I have a process that has been crashing every few days, but needs to be running 24\/7 to be effective. Until I find the time to seek out the cause, I need the process to be restarted.<\/p>\n<p>This short SH script uses PS to check that the process is running, and if not, runs the given init-script to restart the service.<\/p>\n<p>Syntax:<\/p>\n<blockquote><p><code>checkprocess.sh [process] [init-script]<\/code><\/p><\/blockquote>\n<p>Example:<\/p>\n<blockquote><p><code>checkprocess.sh myprocess \/etc\/init.d\/myprocess<\/code><\/p><\/blockquote>\n<p>checkprocess.sh writes a log at \/var\/log\/checkprocess.log, and sends an alert mail to root should the process require restarting.<\/p>\n<p>Put the checkprocess.sh command into crontab to check regular for the crashed process. For debian the crontab entry would look similar to:<br \/>\n<code>*\/1 *   * * *   root    \/usr\/local\/bin\/checkprocess.sh mythbackend \/etc\/init.d\/myth-backend<\/code><\/p>\n<p><b>Download<\/b><br \/>\n<div class=\"wp-downloadmanager\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"wp-downloadmanager-sprite\" aria-hidden=\"true\" focusable=\"false\"><symbol id=\"wp-downloadmanager-icon-file\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M6 2.5h7l5 5v14H6z\" \/><path d=\"M13 2.5v5h5\" \/><\/symbol><symbol id=\"wp-downloadmanager-icon-archive\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M6 2.5h7l5 5v14H6z\" \/><path d=\"M13 2.5v5h5\" \/><path d=\"M11 3h2v2h-2zM11 6h2v2h-2zM11 9h2v2h-2zM10.5 13h3v3.5h-3z\" \/><\/symbol><symbol id=\"wp-downloadmanager-icon-audio\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M6 2.5h7l5 5v14H6z\" \/><path d=\"M13 2.5v5h5\" \/><path d=\"M10 18.5v-5l5-1.5v5\" \/><circle cx=\"9\" cy=\"18.5\" r=\"1.4\" \/><circle cx=\"14\" cy=\"17\" r=\"1.4\" \/><\/symbol><symbol id=\"wp-downloadmanager-icon-code\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M6 2.5h7l5 5v14H6z\" \/><path d=\"M13 2.5v5h5\" \/><path d=\"M10.5 12.5 8 15.5l2.5 3M13.5 12.5 16 15.5l-2.5 3\" \/><\/symbol><symbol id=\"wp-downloadmanager-icon-document\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M6 2.5h7l5 5v14H6z\" \/><path d=\"M13 2.5v5h5\" \/><path d=\"M9 12.5h6M9 15.5h6M9 18.5h4\" \/><\/symbol><symbol id=\"wp-downloadmanager-icon-image\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M6 2.5h7l5 5v14H6z\" \/><path d=\"M13 2.5v5h5\" \/><circle cx=\"10\" cy=\"13.5\" r=\"1.1\" \/><path d=\"M8 19.5l3-3 2 2 3-3.5 2 4.5z\" \/><\/symbol><symbol id=\"wp-downloadmanager-icon-presentation\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M6 2.5h7l5 5v14H6z\" \/><path d=\"M13 2.5v5h5\" \/><path d=\"M9 19.5v-3M12 19.5v-5.5M15 19.5v-8\" \/><\/symbol><symbol id=\"wp-downloadmanager-icon-spreadsheet\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M6 2.5h7l5 5v14H6z\" \/><path d=\"M13 2.5v5h5\" \/><path d=\"M8 12.5h8v7H8zM8 16h8M11.5 12.5v7\" \/><\/symbol><symbol id=\"wp-downloadmanager-icon-video\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M6 2.5h7l5 5v14H6z\" \/><path d=\"M13 2.5v5h5\" \/><path d=\"M10.5 13.5l5 3-5 3z\" \/><\/symbol><symbol id=\"wp-downloadmanager-icon-application\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M6 2.5h7l5 5v14H6z\" \/><path d=\"M13 2.5v5h5\" \/><circle cx=\"12\" cy=\"16.5\" r=\"2\" \/><path d=\"M12 12.5V14M12 19v1.5M8.5 16.5H10M14 16.5h1.5\" \/><\/symbol><\/svg><svg class=\"wp-downloadmanager-icon\" aria-hidden=\"true\" focusable=\"false\"><use href=\"#wp-downloadmanager-icon-file\" \/><\/svg>&nbsp;&nbsp;<strong><a href=\"https:\/\/www.nooblet.org\/blog\/download\/checkprocess.sh\">checkprocess.sh<\/a><\/strong> (723 bytes, 3,135 hits)<br><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have a process that has been crashing every few days, but needs to be running 24\/7 to be effective. Until I find the time to seek out the cause, I need the process to be restarted. This short SH script uses PS to check that the process is running, and if not, runs the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":648,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[35,45,46,233,133,142,143,149],"class_list":["post-64","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-check","tag-cron","tag-crontab","tag-linux","tag-process","tag-restart","tag-script","tag-sh"],"_links":{"self":[{"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/posts\/64","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/comments?post=64"}],"version-history":[{"count":5,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/posts\/64\/revisions"}],"predecessor-version":[{"id":726,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/posts\/64\/revisions\/726"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/media\/648"}],"wp:attachment":[{"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/media?parent=64"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/categories?post=64"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/tags?post=64"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}