{"id":503,"date":"2004-08-27T01:48:33","date_gmt":"2004-08-26T23:48:33","guid":{"rendered":"http:\/\/vasil.ludost.net\/blog\/?p=503"},"modified":"2004-08-27T01:48:33","modified_gmt":"2004-08-26T23:48:33","slug":"2004-08-27-0148","status":"publish","type":"post","link":"https:\/\/vasil.ludost.net\/blog\/?p=503","title":{"rendered":"2004-08-27 01:48"},"content":{"rendered":"<p>Nice, quiet day&#8230; I fixed some small stuff, and again found out that all scripts that are ran from crontab must check for an already running their copy&#8230; Here&#8217;s a template for such scripts:<\/p>\n<pre>\r\n#!\/bin\/sh\r\n#the script's uniqe name\r\nname=SCRIPTNAME\r\n\r\nif [ -f \/var\/run\/$name.pid ]; then\r\n        if [ -d \/proc\/`cat \/var\/run\/$name.pid` ] ; then\r\n                echo $name.sh already running!\r\n                exit 0\r\n        fi\r\nfi\r\n\r\necho $$ > \/var\/run\/$name.pid\r\ntrap \"rm -f \/var\/run\/$name.pid\" exit SIGHUP SIGINT SIGTERM \r\n\r\n#do some stuff\r\necho Ugabugabuga\r\n#cleanup\r\nrm -f \/var\/run\/$name.pid\r\n<\/pre>\n<p>In the moment I&#8217;m sure that it works under linux, because I use \/proc, to check if the pid of the process is still valid, it will work on all unixes, that have such semantics.<\/p>\n<p>In the evening me and Velin watched &#8220;Conspiracy Theory&#8221;, after which I went out for a walk, because most of the day I had stayed at home&#8230; The walk through the center of Sofia in 1:00 is a pleasant one, not a lot of people around, but I was sweating a lot, it was still hot&#8230; When is the autumn coming&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nice, quiet day&#8230; I fixed some small stuff, and again found out that all scripts that are ran from crontab must check for an already running their copy&#8230; Here&#8217;s a template for such scripts: #!\/bin\/sh #the script&#8217;s uniqe name name=SCRIPTNAME if [ -f \/var\/run\/$name.pid ]; then if [ -d \/proc\/`cat \/var\/run\/$name.pid` ] ; then echo [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-503","post","type-post","status-publish","format-standard","hentry","category-general"],"_links":{"self":[{"href":"https:\/\/vasil.ludost.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/503","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vasil.ludost.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vasil.ludost.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vasil.ludost.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vasil.ludost.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=503"}],"version-history":[{"count":0,"href":"https:\/\/vasil.ludost.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/503\/revisions"}],"wp:attachment":[{"href":"https:\/\/vasil.ludost.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=503"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vasil.ludost.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=503"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vasil.ludost.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=503"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}