{"id":903,"date":"2011-04-26T17:49:29","date_gmt":"2011-04-26T17:49:29","guid":{"rendered":"http:\/\/judepereira.com\/blog\/?p=903"},"modified":"2011-04-26T17:49:29","modified_gmt":"2011-04-26T17:49:29","slug":"usrlocalbinwaitpid","status":"publish","type":"post","link":"https:\/\/judepereira.com\/blog\/usrlocalbinwaitpid\/","title":{"rendered":"\/usr\/local\/bin\/waitpid"},"content":{"rendered":"<p> A quick script to wait for a certain pid, then once that quits, execute a command.<br \/>\nYou may ask, why not just do command1 &#038;&#038; command2 ? Well, if command1 exits with a non-zero exit status value, command2 will not get executed. Hence, I&#8217;ve brewed a quick script for this purpose.<\/p>\n<p>File: \/usr\/local\/bin\/waitpid<\/p>\n<pre>\r\n#!\/bin\/sh\r\n# Find the pid of the required process either by using psaux | grep -i command\r\n# or by pidof command\r\n#set -x\r\nif [ $# -ne 3 ]; then\r\n\techo \"Usage: waitpid [pid to wait for] [app name] [command]\"\r\n\techo \"       [command] should be command to execute after pid is dead\"\r\n\texit 1\r\nfi\r\npidr=$1\r\napp=$2\r\nwhile true; do\r\n\tpid=`pidof $app | grep -o $pidr`\r\n\tif [ \"$pid\" = \"$pidr\" ]; then\r\n\t\t# do nothing\r\n\t\techo \"pid does exist,\"\r\n\t\techo \"waiting for 5 seconds before next check\"\r\n\t\tsleep 5\r\n\t\tcontinue\r\n\tfi\r\n\tbreak\r\ndone\r\n# if we've reached here it means that the PID is dead\r\necho \"specified pid does NOT exist,\"\r\necho \"running command provided in 10 seconds\"\r\necho \"\"\r\necho \"Press Ctrl + c to stop\"\r\nsleep 10\r\n$3\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>A quick script to wait for a certain pid, then once that quits, execute a command. You may ask, why not just do command1 &#038;&#038; command2 ? Well, if command1 exits with a non-zero exit status value, command2 will not get executed. Hence, I&#8217;ve brewed a quick script for this purpose. File: \/usr\/local\/bin\/waitpid #!\/bin\/sh # [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"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","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[52,10],"tags":[185,187,186,184,189,188,183],"class_list":["post-903","post","type-post","status-publish","format-standard","hentry","category-code","category-linux","tag-command-execute","tag-detect-pid-end","tag-detect-pid-life","tag-execute-command-after-pid","tag-pid-exit","tag-pid-quit","tag-wait-for-pid"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pqtyx-ez","jetpack-related-posts":[{"id":694,"url":"https:\/\/judepereira.com\/blog\/visual-basic-6-revisited-linux-wine\/","url_meta":{"origin":903,"position":0},"title":"visual basic 6 revisited &#8211; linux &#8211; wine","author":"Jude Pereira","date":"August 5, 2010","format":false,"excerpt":"Earlier this year, I had written an article on running Visual Basic 6 on linux under wine, this is an update for it, the prior one is deprecated Getting Visual Basic 6 to work on linux is pretty easy, not much trouble, all the basic things work, as of what\u2026","rel":"","context":"In &quot;another snippet | code&quot;","block_context":{"text":"another snippet | code","link":"https:\/\/judepereira.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1648,"url":"https:\/\/judepereira.com\/blog\/openwrt-wont-bring-my-wifi-interface-up-unless-the-other-is-up\/","url_meta":{"origin":903,"position":1},"title":"OpenWRT won&#8217;t bring my WiFi interface up, unless the other is up","author":"Jude Pereira","date":"September 25, 2015","format":false,"excerpt":"I recently bought a D-Link DIR 505 router. So far, I've got a DLNA server running on it, along with Transmission, a bit torrent client. Life is awesome so far. I set it up to repeat another WiFi router in my house, the one connected to the internet - using\u2026","rel":"","context":"In &quot;another snippet | code&quot;","block_context":{"text":"another snippet | code","link":"https:\/\/judepereira.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":893,"url":"https:\/\/judepereira.com\/blog\/coloured-varlogmessages-at-tty12\/","url_meta":{"origin":903,"position":2},"title":"Coloured \/var\/log\/messages at tty12","author":"Jude Pereira","date":"April 26, 2011","format":false,"excerpt":"Reading logs could never become any more easier, at just a keystroke, you have your logs displayed where you want, in some fancy colour. They look great too. TTY's can be accessed by pressing Alt + Ctrl + F[1 - 12] simultaneously. In the following, you'll get a decent, colourized\u2026","rel":"","context":"In &quot;another snippet | code&quot;","block_context":{"text":"another snippet | code","link":"https:\/\/judepereira.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1881,"url":"https:\/\/judepereira.com\/blog\/nrf52840-flash-s340\/","url_meta":{"origin":903,"position":3},"title":"nRF52840 &#8211; flashing the s340 v6.1.1 SoftDevice","author":"Jude Pereira","date":"July 12, 2019","format":false,"excerpt":"This post is a work in progress (WIP). The result of this experiment is a success. I have flashed my SparkFun nRF52840 mini, and I'm able to run the bicycle combined speed & cadence sensor example. Before we begin, \u00a0a big hats off to\u00a0Charles, who brought support for the SparkFun\u2026","rel":"","context":"In &quot;hardware&quot;","block_context":{"text":"hardware","link":"https:\/\/judepereira.com\/blog\/category\/hardware\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1855,"url":"https:\/\/judepereira.com\/blog\/nginx-ingress-helm-k8s-rbac\/","url_meta":{"origin":903,"position":4},"title":"Installing the Nginx Ingress Controller via Helm to a K8s cluster with RBAC enabled","author":"Jude Pereira","date":"October 1, 2018","format":false,"excerpt":"A lot of posts describe how to do this, but are fairly outdated, and do not mention the last supported K8s version. Here's a tried and tested way to do so via Helm. This has been tested on GKE, with the Kubernetes master version\u00a01.9.7-gke.6: Create the service account for Tiller\u2026","rel":"","context":"In &quot;another snippet | code&quot;","block_context":{"text":"another snippet | code","link":"https:\/\/judepereira.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1685,"url":"https:\/\/judepereira.com\/blog\/compile-less-on-the-fly-for-your-exploded-war-in-intellij\/","url_meta":{"origin":903,"position":5},"title":"Compile LESS on the fly for your exploded WAR in IntelliJ","author":"Jude Pereira","date":"February 5, 2016","format":false,"excerpt":"At CleverTap, we've recently started using LESS for dynamic CSS. While it has it's upsides, the biggest downside\u00a0was that most of our developers couldn't use the hot deploy feature for their local deployments. After an hour or so, we came up with a neat solution. \u00a0 There are two parts\u2026","rel":"","context":"In &quot;another snippet | code&quot;","block_context":{"text":"another snippet | code","link":"https:\/\/judepereira.com\/blog\/category\/code\/"},"img":{"alt_text":"External Tool configuration for compiling LESS files before deployment","src":"https:\/\/i0.wp.com\/judepereira.com\/blog\/wp-content\/uploads\/Screen-Shot-2016-02-05-at-01.32.45-1024x494.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/judepereira.com\/blog\/wp-content\/uploads\/Screen-Shot-2016-02-05-at-01.32.45-1024x494.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/judepereira.com\/blog\/wp-content\/uploads\/Screen-Shot-2016-02-05-at-01.32.45-1024x494.png?resize=525%2C300 1.5x"},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/posts\/903","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/comments?post=903"}],"version-history":[{"count":7,"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/posts\/903\/revisions"}],"predecessor-version":[{"id":910,"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/posts\/903\/revisions\/910"}],"wp:attachment":[{"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/media?parent=903"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/categories?post=903"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/tags?post=903"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}