{"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<img decoding=\"async\" src=\"\/blog\/wp-content\/plugins\/wp-downloadmanager\/images\/ext\/unknown.gif\" alt=\"\" title=\"\" style=\"vertical-align: middle;\" \/>&nbsp;&nbsp;<strong><a href=\"https:\/\/www.nooblet.org\/blog\/download\/checkprocess.sh\">checkprocess.sh<\/a><\/strong> (723 bytes, 3,043 hits)<br><\/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}]}}