{"id":277,"date":"2010-07-22T20:29:00","date_gmt":"2010-07-22T20:29:00","guid":{"rendered":"http:\/\/poojanwagh.opalstacked.com\/techblog\/?p=277"},"modified":"2010-07-22T20:29:00","modified_gmt":"2010-07-22T20:29:00","slug":"limit-number-of-instances-of-a-specific-process-and-user","status":"publish","type":"post","link":"https:\/\/tech.poojanblog.com\/blog\/unix-linux\/limit-number-of-instances-of-a-specific-process-and-user\/","title":{"rendered":"Limit number of instances of a specific process and user"},"content":{"rendered":"<p>I&#8217;m using this to limit the number of processes that <a href=\"http:\/\/poojanwagh.opalstacked.com\/techblog\/mobile\/ampache-mobile-rocks\/\" title=\"Ampache (+Mobile) Rocks!\">Ampache<\/a> spawns. Sometimes, it goes hay-wire.<\/p>\n<p>[cc_bash]<br \/>\n#!\/bin\/sh<\/p>\n<p>cmd=&#8221;$1&#8243;<br \/>\nlim=&#8221;$2&#8243;<br \/>\nuser=&#8221;$3&#8243; || &#8220;www&#8221;<br \/>\nnumprocs=`ps -U www | grep &#8220;$cmd&#8221; | wc -l`<br \/>\necho &#8220;Found $numprocs comparing to $lim&#8221;<br \/>\nif [ &#8220;$numprocs&#8221; -gt &#8220;$lim&#8221; ]; then<br \/>\n        echo &#8220;found $numprocs processes&#8221;<br \/>\n        killall aacplusenc<br \/>\nfi<br \/>\n[\/cc_bash]<\/p>\n<div class='wp_likes' id='wp_likes_post-277'><a class='like' href=\"javascript:wp_likes.like(277);\" title='' ><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/tech.poojanblog.com\/blog\/wp-content\/plugins\/wp-likes\/images\/like.png\" alt='' border='0'\/><\/a><span class='text'>Be the first to like.<\/span><\/p>\n<div class='like' ><a href=\"javascript:wp_likes.like(277);\">Like<\/a><\/div>\n<div class='unlike' ><a href=\"javascript:wp_likes.unlike(277);\">Unlike<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m using this to limit the number of processes that Ampache spawns. Sometimes, it goes hay-wire. [cc_bash] #!\/bin\/sh cmd=&#8221;$1&#8243; lim=&#8221;$2&#8243; user=&#8221;$3&#8243; || &#8220;www&#8221; numprocs=`ps -U www | grep &#8220;$cmd&#8221; | wc -l` echo &#8220;Found $numprocs comparing to $lim&#8221; if [ &#8220;$numprocs&#8221; -gt &#8220;$lim&#8221; ]; then echo &#8220;found $numprocs processes&#8221; killall aacplusenc fi [\/cc_bash] Be the [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[10],"tags":[100,106,105,86,107],"class_list":["post-277","post","type-post","status-publish","format-standard","hentry","category-unix-linux","tag-bash","tag-limit","tag-process","tag-ps","tag-user"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/posts\/277","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/comments?post=277"}],"version-history":[{"count":1,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/posts\/277\/revisions"}],"predecessor-version":[{"id":278,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/posts\/277\/revisions\/278"}],"wp:attachment":[{"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/media?parent=277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/categories?post=277"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/tags?post=277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}