{"id":75,"date":"2010-02-01T14:54:38","date_gmt":"2010-02-01T13:54:38","guid":{"rendered":"http:\/\/toderu.ro\/blog\/?p=75"},"modified":"2010-02-01T14:54:38","modified_gmt":"2010-02-01T13:54:38","slug":"bash-script-to-check-if-an-daemon-is-running-and-restart","status":"publish","type":"post","link":"https:\/\/kb.toderu.ro\/?p=75","title":{"rendered":"bash script to check if an daemon is running and restart"},"content":{"rendered":"<p>\t\t\t\t<code>#!\/bin\/sh<br \/>\nSERVICE='named'<br \/>\nif ps ax | grep -v grep | grep $SERVICE > \/dev\/null<br \/>\nthen<br \/>\ncat \/dev\/null<br \/>\nelse<br \/>\n    echo \"$SERVICE is not running... starting\"<br \/>\n    \/etc\/init.d\/$SERVICE restart | mail -s \"$SERVICE restarted\" email@domain.tld<br \/>\nfi<\/code><\/p>\n<p>p.s. do not name the script as the service \ud83d\ude42\t\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>#!\/bin\/sh SERVICE=&#8217;named&#8217; if ps ax | grep -v grep | grep $SERVICE > \/dev\/null then cat \/dev\/null else echo &#8220;$SERVICE is not running&#8230; starting&#8221; \/etc\/init.d\/$SERVICE restart | mail -s &#8220;$SERVICE restarted&#8221; email@domain.tld fi p.s. do not name the script as the service \ud83d\ude42<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20,5],"tags":[],"class_list":["post-75","post","type-post","status-publish","format-standard","hentry","category-bash-scripting","category-linux"],"_links":{"self":[{"href":"https:\/\/kb.toderu.ro\/index.php?rest_route=\/wp\/v2\/posts\/75","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kb.toderu.ro\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kb.toderu.ro\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kb.toderu.ro\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kb.toderu.ro\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=75"}],"version-history":[{"count":0,"href":"https:\/\/kb.toderu.ro\/index.php?rest_route=\/wp\/v2\/posts\/75\/revisions"}],"wp:attachment":[{"href":"https:\/\/kb.toderu.ro\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=75"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kb.toderu.ro\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=75"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kb.toderu.ro\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=75"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}