{"id":745,"date":"2014-09-23T12:49:47","date_gmt":"2014-09-23T19:49:47","guid":{"rendered":"http:\/\/blog.ls-al.com\/?p=745"},"modified":"2014-09-23T12:49:59","modified_gmt":"2014-09-23T19:49:59","slug":"watch-process-id","status":"publish","type":"post","link":"https:\/\/blog.ls-al.com\/watch-process-id\/","title":{"rendered":"Watch Process Id"},"content":{"rendered":"
Sometimes you want to keep tabs on a long running process and get notified by email when it is done. This is an example of just that.<\/p>\n
\r\n#!\/bin\/bash\r\npid=$1\r\nme="$(basename $0)($$):"\r\nif [ -z "$pid" ]\r\nthen\r\n echo "$me a PID is required as an argument" >&2\r\n exit 2\r\nfi\r\n\r\nname=$(ps -p $pid -o comm=)\r\nif [ $? -eq 0 ]\r\nthen\r\n echo "$me waiting for PID $pid to finish ($name)"\r\n while ps -p $pid > \/dev\/null; do sleep 1; done;\r\nelse\r\n echo "$me failed to find process with PID $pid" >&2\r\n exit 1\r\nfi\r\n## I used a python mailer but mostlikely this will be mail or mailx.\r\npython pymail.py $pid\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"Sometimes you want to keep tabs on a long running process and get notified by email when it is done.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,1],"tags":[],"class_list":["post-745","post","type-post","status-publish","format-standard","hentry","category-bash","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/745","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/comments?post=745"}],"version-history":[{"count":0,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/745\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/media?parent=745"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/categories?post=745"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/tags?post=745"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}