OpenVZ Forum


Home » General » Support » *DISCUSSION* OVZ command to start/stop VE based on status.
*DISCUSSION* OVZ command to start/stop VE based on status. [message #14722] Sun, 08 July 2007 14:04 Go to next message
joelee is currently offline  joelee
Messages: 63
Registered: April 2006
Member
Hi All, I was wondering if there's a command where I can start or stop a VPS based on there status. For Example:

- Only start all VPS that have status "stop".
- Stop all VPS with status "running" or "started"...

I would like to see other similar type commands that would take effect on multiple VPSs. If there already exist those type of commands I'd appreciate a link to the resource to read up on it!

Thanks - Joe

[Updated on: Wed, 11 July 2007 07:41] by Moderator

Report message to a moderator

Re: OVZ command to start/stop VE based on status. [message #14730 is a reply to message #14722] Mon, 09 July 2007 10:00 Go to previous messageGo to next message
n00b_admin is currently offline  n00b_admin
Messages: 77
Registered: July 2006
Location: Romania
Member
You could write a bash script that does this...

I don't think is very hard...

You look into /etc/vz/conf dir and construct a loop that searches config files and you read the veid from the filename.

After that you grep a status command on that veid and take the action that you want depending of the status.
Re: OVZ command to start/stop VE based on status. [message #14737 is a reply to message #14730] Mon, 09 July 2007 11:20 Go to previous messageGo to next message
joelee is currently offline  joelee
Messages: 63
Registered: April 2006
Member
Yeah, I suppose a scrip can do this. But, for a user like me, I don't have much linux/sysadmin skills to know how to build the script. I have some general knowledge about it though and can learn - I'll be researching that. However, I don't think it would be that difficult to build this in the OVZ command line.

Thanks for your input!

-joe
Re: OVZ command to start/stop VE based on status. [message #14740 is a reply to message #14722] Mon, 09 July 2007 12:13 Go to previous messageGo to next message
n00b_admin is currently offline  n00b_admin
Messages: 77
Registered: July 2006
Location: Romania
Member
Because is such a trivial task to do, i don't think the devs will do it, but let's hear from them regarding that.

Since you only need some basic knowledge of linux tools you could do it (and make it public if you want to) and learn from the experience.

Re: OVZ command to start/stop VE based on status. [message #14790 is a reply to message #14740] Tue, 10 July 2007 19:19 Go to previous messageGo to next message
joelee is currently offline  joelee
Messages: 63
Registered: April 2006
Member
Sure thing, I am already looking to do this with a script for the know-how. I'll publish it if it all works!
Re: OVZ command to start/stop VE based on status. [message #14795 is a reply to message #14730] Wed, 11 July 2007 00:25 Go to previous messageGo to next message
curx
Messages: 739
Registered: February 2006
Location: Nürnberg, Germany
Senior Member

Hi,

use the command "vzlist" to determine the stati of VE's,
more help with vzlist (-> man page of vzlist).

# start all stopped VE's
for VE in `vzlist -SHoveid`; do
echo $VE
vzctl start $VE
done

# stop all running VE's
for VE in `vzlist -SHoveid`; do
echo $VE
vzctl start $VE
done

Re: OVZ command to start/stop VE based on status. [message #14802 is a reply to message #14790] Wed, 11 July 2007 07:41 Go to previous message
Vasily Tarasov is currently offline  Vasily Tarasov
Messages: 1345
Registered: January 2006
Senior Member
Joelee,

I also think, that such commands are not very necessary to be included in vzctl package: simple scripts can be written by the administrator to do this work.

However, if you write quite a big an reasonable set of such scripts - we will put it to contrib area at http://download.openvz.org.

Also, it'll be a good ide to create a wiki at http://wiki.openvz.org titled "Scripts for actions on multiple VEs" or alike.

Summary: your contributions are always welcome Smile

Thanks,
Vasily.
Previous Topic: *BUG REPORTED* vzmigrate with NFS
Next Topic: *KNOWN ISSUE* Problems with online migration on 031 kernel
Goto Forum:
  


Current Time: Sat Nov 16 15:22:27 GMT 2024

Total time taken to generate the page: 0.02938 seconds