Jump to content
Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
NickTheGreek

Execute a command in all running OpenVZ Containers

Recommended Posts

Execute a command in all running OpenVZ Containers

If you wish to execute a command in all running Containers, you can use the following script:

for i in `cat /proc/vz/veinfo | awk '{print $1}'|egrep -v '^0$'`; \ do echo "Container $i"; vzctl exec $i <command>; done

 

 

where <command> is the command to be executed in all the running Containers. For example:

for i in `cat /proc/vz/veinfo | awk '{print $1}'|egrep -v '^0$'`; \ do echo "Container $i"; vzctl exec $i uptime; done

 

Container 1
2:26pm up 6 days, 1:28, 0 users, load average: 0.00, 0.00, 0.00
Container 101
2:26pm up 6 days, 1:39, 0 users, load average: 0.00, 0.00, 0.00

Source: http://download.swsoft.com/virtuozzo/virtuozzo4.0/docs/en/lin/VzLinuxUG/260.htm

 

  • Like 2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×