{"id":712,"date":"2013-11-04T10:07:40","date_gmt":"2013-11-04T03:07:40","guid":{"rendered":"http:\/\/whplus.com\/blog\/?p=712"},"modified":"2013-11-04T10:10:30","modified_gmt":"2013-11-04T03:10:30","slug":"openvz-scripts","status":"publish","type":"post","link":"https:\/\/www.whplus.com\/blog\/2013\/11\/04\/openvz-scripts.html","title":{"rendered":"openvz scripts"},"content":{"rendered":"<p>In this article, we&#8217;ve put some small scripts that useful for openvz<\/p>\n<p><strong>vzstartall.sh<\/strong><br \/>\n<code>#!\/bin\/bash<br \/>\n## vzstartall - starts all openvz containers that are currently stopped<br \/>\nfor arg in `vzlist -HS -o ctid`<br \/>\ndo<br \/>\n  echo working on container $arg<br \/>\n  sudo vzctl start $arg<br \/>\ndone<\/code><\/p>\n<p><strong>vzstopall.sh<\/strong><br \/>\n<code>#!\/bin\/bash<br \/>\n## vzstopall - stops all running openvz containers<br \/>\necho stopping all running openvz containers<br \/>\nfor arg in `vzlist -H -o ctid`<br \/>\ndo<br \/>\n  echo working on container $arg<br \/>\n  sudo vzctl stop $arg<br \/>\ndone<\/code><br \/>\n<!--more--><br \/>\n<strong>vzrestartall.sh<\/strong><br \/>\n<code>#!\/bin\/bash<br \/>\n## vzrestartall - restarts all openvz containers that are running<br \/>\nfor arg in `vzlist -H -o ctid`<br \/>\ndo<br \/>\n  echo working on container $arg<br \/>\n  sudo vzctl stop $arg<br \/>\n  sudo vzctl start $arg<br \/>\ndone<\/code><\/p>\n<p><strong>vzdiskspace.sh<\/strong><br \/>\n<code>#!\/bin\/bash<br \/>\n(echo \"Hostname SpaceAllocated  SpaceUsed  SpaceRemaining  Percent Filesystem\"<br \/>\nfor arg in `sudo vzlist -H -o ctid`<br \/>\ndo<br \/>\n       hostname=`sudo vzlist -H -o ctid,hostname | grep $arg | sed \"s\/$arg\/\/g\" - | sed 's\/^[ \\t]*\/\/' - | sed 's\/[ \\t]*$\/\/' -`<br \/>\n       space=`sudo vzctl exec $arg df -h | grep \/$ | sed 's\/simfs\/\/g' | sed 's\/^[ \\t]*\/\/' - | sed 's\/[ \\t]*$\/\/' -`<br \/>\n       echo \"$hostname $space\"<br \/>\ndone ) | column -t<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we&#8217;ve put some small scripts that useful for openvz vzstartall.sh #!\/bin\/bash ## vzstartall &#8211; starts all openvz containers that are currently stopped for arg in `vzlist -HS -o ctid` do echo working on container $arg sudo vzctl start $arg done vzstopall.sh #!\/bin\/bash ## vzstopall &#8211; stops all running openvz containers echo stopping\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.whplus.com\/blog\/2013\/11\/04\/openvz-scripts.html\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-712","post","type-post","status-publish","format-standard","hentry","category-tutorial"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.whplus.com\/blog\/wp-json\/wp\/v2\/posts\/712","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.whplus.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.whplus.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.whplus.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.whplus.com\/blog\/wp-json\/wp\/v2\/comments?post=712"}],"version-history":[{"count":3,"href":"https:\/\/www.whplus.com\/blog\/wp-json\/wp\/v2\/posts\/712\/revisions"}],"predecessor-version":[{"id":715,"href":"https:\/\/www.whplus.com\/blog\/wp-json\/wp\/v2\/posts\/712\/revisions\/715"}],"wp:attachment":[{"href":"https:\/\/www.whplus.com\/blog\/wp-json\/wp\/v2\/media?parent=712"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.whplus.com\/blog\/wp-json\/wp\/v2\/categories?post=712"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.whplus.com\/blog\/wp-json\/wp\/v2\/tags?post=712"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}