{"id":85,"date":"2012-10-04T10:59:25","date_gmt":"2012-10-04T10:59:25","guid":{"rendered":"http:\/\/ethaizone.com\/blog\/?p=85"},"modified":"2012-10-04T11:05:57","modified_gmt":"2012-10-04T11:05:57","slug":"auto-restart-faxgetty-when-modem-crash","status":"publish","type":"post","link":"https:\/\/ethaizone.me\/blog\/2012\/10\/auto-restart-faxgetty-when-modem-crash\/","title":{"rendered":"Auto restart faxgetty when modem crash"},"content":{"rendered":"<p>Hi everybody in our world. I hope you have good health. Today I will paste my simple php code that I used in company server. My server got some problem that I don&#8217;t know what is source of this problem. I use Hylafax with Avantfax. Both of them update lasted version on Ubuntu 10.10. I know only it&#8217;s about segfault. I found some log at \/var\/log\/messages and I don&#8217;t know anymore.<\/p>\n<p>\/&#8230;<\/p>\n<p>I found php script in some website but I use 2 modem. (1 external 1 internal) That php script didn&#8217;t work so I modified script. It&#8217;s very simple version. I don&#8217;t put any license to it so you can modify it freely.<\/p>\n<p><img src=\"http:\/\/ethaizone.me\/blog\/wp-includes\/images\/smilies\/3_009.gif\" alt=\"\/ee\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/><\/p>\n<pre class=\"brush:php\">&lt;?php\r\n\/**\r\n* Check if faxgetty runs and if not restart the service\r\n* It's about segfault. \/var\/log\/messages\r\n*\r\n* For two modem by EThaiZone.com\r\n*\/\r\n\r\n$process='faxgetty'; \/\/process\r\n$command=\"ps -Al -cmd| grep \".$process; \/\/command !!!\r\n\r\nob_start();\r\npassthru($command); \/\/execute command\r\n$result=ob_get_contents();\r\nob_end_clean();\r\n\r\nif(preg_match('#'.$process.'\\r?\\n.+'.$process.'#', $result))\r\n{\r\n\techo \"No problem. Faxgetty run fine.\\n\"; \/\/OK\r\n}\r\nelse\r\n{\r\n\techo \"Restart hylafax\\n\";\r\n\texec(\"service hylafax restart\");\r\n}\r\n\r\n?&gt;<\/pre>\n<p>Save it and run it via cronjob. I recommend to run every seconds because it don&#8217;t cause load on cpu that should worry. In my cron I put this.<\/p>\n<pre class=\"brush:shell\">* * * * *   php -q \/checkfaxgetty.php<\/pre>\n<p>I hope this&#8217;s useful to you.\u00a0 <img src=\"http:\/\/ethaizone.me\/blog\/wp-includes\/images\/smilies\/th_v14.gif\" alt=\"\/bye\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi everybody in our world. I hope you ha &hellip; <a href=\"https:\/\/ethaizone.me\/blog\/2012\/10\/auto-restart-faxgetty-when-modem-crash\/\">\u0e2d\u0e48\u0e32\u0e19\u0e40\u0e1e\u0e34\u0e48\u0e21\u0e40\u0e15\u0e34\u0e21 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[3,7],"tags":[],"class_list":["post-85","post","type-post","status-publish","format-standard","hentry","category-coding","category-ubuntu"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2Iqnv-1n","_links":{"self":[{"href":"https:\/\/ethaizone.me\/blog\/wp-json\/wp\/v2\/posts\/85"}],"collection":[{"href":"https:\/\/ethaizone.me\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ethaizone.me\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ethaizone.me\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ethaizone.me\/blog\/wp-json\/wp\/v2\/comments?post=85"}],"version-history":[{"count":0,"href":"https:\/\/ethaizone.me\/blog\/wp-json\/wp\/v2\/posts\/85\/revisions"}],"wp:attachment":[{"href":"https:\/\/ethaizone.me\/blog\/wp-json\/wp\/v2\/media?parent=85"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ethaizone.me\/blog\/wp-json\/wp\/v2\/categories?post=85"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ethaizone.me\/blog\/wp-json\/wp\/v2\/tags?post=85"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}