{"id":54,"date":"2006-09-07T14:52:04","date_gmt":"2006-09-07T13:52:04","guid":{"rendered":"http:\/\/blogs.igalia.com\/eocanha\/?p=54"},"modified":"2015-11-08T00:21:11","modified_gmt":"2015-11-07T23:21:11","slug":"limited-lifetime-scripts","status":"publish","type":"post","link":"https:\/\/eocanha.org\/blog\/2006\/09\/07\/limited-lifetime-scripts\/","title":{"rendered":"Limited lifetime scripts"},"content":{"rendered":"<p>While helping <a href=\"http:\/\/blogs.igalia.com\/xavi\/\">Xavi<\/a> with a small task (batch converting ODT documents to PDF via a web form), I&#8217;ve remembered a little recipe I&#8217;ve written some time ago.<\/p>\n<p>It&#8217;s a way to force some script to die after a defined timeout. So, you can perform a command by ssh inside a script or perform any blocking task you want, and it will always return.<\/p>\n<p>The only thing you have to do is to put these single 3 lines of code at the start of your bash script:<\/p>\n<p><tt>SECURITY_TIMEOUT=60<br \/>\nCMD_PID=\"$$\";<br \/>\n{ sleep $SECURITY_TIMEOUT;  kill -9 $CMD_PID; } 2&gt;\/dev\/null &amp;<br \/>\n<\/tt>Enjoy it!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>While helping Xavi with a small task (batch converting ODT documents to PDF via a web form), I&#8217;ve remembered a little recipe I&#8217;ve written some time ago. It&#8217;s a way to force some script to die after a defined timeout. So, you can perform a command by ssh inside a script or perform any blocking &hellip; <a href=\"https:\/\/eocanha.org\/blog\/2006\/09\/07\/limited-lifetime-scripts\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Limited lifetime scripts<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/eocanha.org\/blog\/wp-json\/wp\/v2\/posts\/54"}],"collection":[{"href":"https:\/\/eocanha.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eocanha.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eocanha.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/eocanha.org\/blog\/wp-json\/wp\/v2\/comments?post=54"}],"version-history":[{"count":1,"href":"https:\/\/eocanha.org\/blog\/wp-json\/wp\/v2\/posts\/54\/revisions"}],"predecessor-version":[{"id":445,"href":"https:\/\/eocanha.org\/blog\/wp-json\/wp\/v2\/posts\/54\/revisions\/445"}],"wp:attachment":[{"href":"https:\/\/eocanha.org\/blog\/wp-json\/wp\/v2\/media?parent=54"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eocanha.org\/blog\/wp-json\/wp\/v2\/categories?post=54"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eocanha.org\/blog\/wp-json\/wp\/v2\/tags?post=54"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}