{"id":3301,"date":"2014-07-06T11:02:20","date_gmt":"2014-07-06T03:02:20","guid":{"rendered":"http:\/\/rmohan.com\/?p=3301"},"modified":"2014-07-06T11:02:20","modified_gmt":"2014-07-06T03:02:20","slug":"restart-of-service","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=3301","title":{"rendered":"restart of service"},"content":{"rendered":"<pre style=\"color: #000000; text-transform: none; line-height: normal; text-indent: 0px; letter-spacing: normal; font-style: normal; font-variant: normal; font-weight: normal; word-spacing: 0px; white-space: pre-wrap; -ms-word-wrap: break-word; -webkit-text-stroke-width: 0px;\"><br class=\"Apple-interchange-newline\" \/>\r\necho\r\nis_uid=`\/usr\/bin\/id | \/usr\/bin\/awk -F\\= {'print $2'} | \/usr\/bin\/awk -F\\( {'print $1'}`\r\nif [ $is_uid -ne 0 ] ; then\r\n\techo \"You are not logged on as root\"\r\n\texit ;\r\nfi\r\n\r\n\r\n# DNS, name server, bind ;\r\ncase \"$1\" in\r\n'dns'|'bind'|'named')\r\n\tif [ -f \"\/usr\/local\/etc\/named.pid\" ] ; then \r\n\t\tnamed_pid=`cat \/usr\/local\/etc\/named.pid` \r\n\t\tkill -HUP $named_pid\r\n\t\techo \"DNS restarted $named_pid\"\r\n\t\t\/usr\/bin\/ps -ef | \/usr\/bin\/fgrep -v grep | \/usr\/bin\/fgrep -v restart | \/usr\/bin\/fgrep name  | \/usr\/bin\/awk {'print $9'}  \r\n\telse \r\n\t\techo \"You don't seem to be running the BIND nameserver\"\r\n\t\techo \"with a pid in \/usr\/local\/etc\/bind.conf\"\r\n\tfi\r\n;;\r\n\r\n'apache'|'http'|'httpd'|'web')\r\n\tif [ -f \"\/usr\/local\/apache\/logs\/httpd.pid\" ] ; then \r\n\t\thttpd_pid=`cat \/usr\/local\/apache\/logs\/httpd.pid`\r\n\telse \r\n\t\thttpd_pid=\"not in \/usr\/local\/apache\/logs\/httpd.pid\" \r\n\tfi\r\n\tif [ -f \"\/usr\/local\/apache\/bin\/apachectl\" ] ; then \r\n\t\t\/usr\/local\/apache\/bin\/apachectl restart\r\n\t\techo \"Apache restarting\"\r\n\t\tsleep 1 ;\r\n\t\t\/usr\/bin\/ps -ef | \/usr\/bin\/fgrep -v grep | \/usr\/bin\/fgrep -v restart | \/usr\/bin\/fgrep apach | \/usr\/bin\/awk {'print $8'}\r\n\t\techo \"Parent process is $httpd_pid\"\r\n\telse \r\n\t\techo \"You don't have the apachectl file in \/usr\/local\/apache\/bin\"\r\n\tfi\r\n;;\r\n\r\n'mail'|'sendmail')\r\n\tsendmail_pid=0\r\n\tif [ -f \/etc\/mail\/sendmail.pid ]; then\r\n\t\tsendmail_pid=`\/usr\/bin\/head -1 \/etc\/mail\/sendmail.pid` \r\n\t\tkill -HUP $sendmail_pid\r\n\t\techo \"Sendmail restarted $sendmail_pid\"\r\n\t\t\/usr\/bin\/ps -ef | \/usr\/bin\/fgrep -v grep | \/usr\/bin\/fgrep -v restart | \/usr\/bin\/fgrep mail  | \/usr\/bin\/awk {'print $8 \" \" $9  \" \" $10'}  \r\n\t\techo $sendmail_pid\r\n\tfi \r\n        if [ -f \/var\/run\/sendmail.pid ]; then\r\n                sendmail_pid=`\/usr\/bin\/head -1 \/var\/run\/sendmail.pid`\r\n                kill -HUP $sendmail_pid\r\n                echo \"Sendmail restarted $sendmail_pid\"\r\n                \/usr\/bin\/ps -ef | \/usr\/bin\/fgrep -v grep | \/usr\/bin\/fgrep -v restart | \/usr\/bin\/fgrep mail  | \/usr\/bin\/awk {'print $8 \" \" $9  \" \" $10'}\r\n\t\techo $sendmail_pid\r\n\tfi\r\n\tif [ $sendmail_pid -eq 0 ]; then\r\n\t\techo \"You don't have the sendmail parent process\"\r\n\t\techo \"number in \/etc\/mail\/sendmail.pid\"\r\n\t\techo \"or in \/var\/run\/sendmail.pid\"\r\n\tfi\r\n;;\r\n\r\n\r\n'syslog')\r\n\tif [ -f  \/etc\/syslog.pid ] ; then \r\n\t\tsyslog_pid=`cat \/etc\/syslog.pid` \r\n\t\tkill -HUP $syslog_pid\r\n\t\techo \"Syslog restarted $syslog_pid\"\r\n\t\t\/usr\/bin\/ps -ef | \/usr\/bin\/fgrep -v grep | \/usr\/bin\/fgrep -v restart | \/usr\/bin\/fgrep syslog | \/usr\/bin\/awk {'print $9'}\r\n\telse\r\n\t\techo \"\/etc\/syslog.pid does not exist\" \r\n\tfi\r\n\t;;\r\n\r\n'inetd')\r\n        pkill -HUP inetd\r\n        echo \"Inetd restarted $inetd_pid\"\r\n        \/usr\/bin\/ps -ef | \/usr\/bin\/fgrep -v grep | \/usr\/bin\/fgrep -v restart | \/usr\/bin\/fgrep inetd | \/usr\/bin\/awk {'print $8 \"  \" $9 \" \" $10'}\r\n;;\r\n\r\n*) \r\n\techo \"Syntax Error -&gt; restart option\"\r\n\techo \"restart apache|bind|dns|http|httpd|inetd|mail|named|syslog|web\"\r\n\techo\r\n;;\r\n\r\nesac\r\necho \r\nexit<\/pre>\n","protected":false},"excerpt":{"rendered":"<p> echo is_uid=`\/usr\/bin\/id | \/usr\/bin\/awk -F\\= {&#8216;print $2&#8217;} | \/usr\/bin\/awk -F\\( {&#8216;print $1&#8217;}` if [ $is_uid -ne 0 ] ; then echo &#8220;You are not logged on as root&#8221; exit ; fi # DNS, name server, bind ; case &#8220;$1&#8221; in &#8216;dns&#8217;|&#8217;bind&#8217;|&#8217;named&#8217;) if [ -f &#8220;\/usr\/local\/etc\/named.pid&#8221; ] ; then named_pid=`cat \/usr\/local\/etc\/named.pid` kill -HUP $named_pid echo [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[47],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/3301"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3301"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/3301\/revisions"}],"predecessor-version":[{"id":3302,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/3301\/revisions\/3302"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}