OpenVZ Forum


Home » General » Support » *SOLVED* vzctl restart from crontab
*SOLVED* vzctl restart from crontab [message #14612] Tue, 03 July 2007 12:58 Go to next message
jonasb is currently offline  jonasb
Messages: 20
Registered: July 2007
Junior Member
Im trying to restart a VE from crontab. But I get "operation timed out" everytime.

*/2 * * * * /usr/sbin/vzctl restart 666 >>/tmp/log 2>&1

cat /tmp/log

Restarting VE
Stopping VE ...
Unable to stop VE: operation timed out

I have tried "vzctl stop" with the same results. But "vzctl start" works.
If I run it from normal shell it works.

Any ideas?

[Updated on: Thu, 05 July 2007 08:48] by Moderator

Report message to a moderator

Re: vzctl restart from crontab [message #14642 is a reply to message #14612] Wed, 04 July 2007 06:13 Go to previous messageGo to next message
boredbadger is currently offline  boredbadger
Messages: 4
Registered: July 2007
Junior Member
Try forking the script into the background rather than making crond wait for the command to finish by adding a &.

*/2 * * * * /usr/sbin/vzctl restart 666 & >>/tmp/log 2>&1

That should force it to work in the background so you shouldn't get a time out.

Neil

[Updated on: Wed, 04 July 2007 06:13]

Report message to a moderator

Re: vzctl restart from crontab [message #14645 is a reply to message #14642] Wed, 04 July 2007 06:36 Go to previous messageGo to next message
jonasb is currently offline  jonasb
Messages: 20
Registered: July 2007
Junior Member
I didn't help. Sad
Re: vzctl restart from crontab [message #14646 is a reply to message #14645] Wed, 04 July 2007 06:44 Go to previous messageGo to next message
boredbadger is currently offline  boredbadger
Messages: 4
Registered: July 2007
Junior Member
What about putting the command into a bash script and running a that as a cron?
Re: vzctl restart from crontab [message #14647 is a reply to message #14646] Wed, 04 July 2007 06:52 Go to previous messageGo to next message
jonasb is currently offline  jonasb
Messages: 20
Registered: July 2007
Junior Member
That didnt help either.

# cat /root/restart.sh
#!/bin/bash
/usr/sbin/vzctl restart 666 >>/tmp/ll 2>&1
Re: vzctl restart from crontab [message #14654 is a reply to message #14647] Wed, 04 July 2007 12:37 Go to previous messageGo to next message
rickb is currently offline  rickb
Messages: 368
Registered: October 2006
Senior Member
is your $PATH env variable the same when running under cron vs sshd bash shell?

-------------
Common Terms I post with: http://wiki.openvz.org/Category:Definitions

UBC. Learn it, love it, live it: http://wiki.openvz.org/Proc/user_beancounters
Re: vzctl restart from crontab [message #14658 is a reply to message #14654] Wed, 04 July 2007 13:54 Go to previous messageGo to next message
jonasb is currently offline  jonasb
Messages: 20
Registered: July 2007
Junior Member
No, the $PATH was not the same.
After I set the same $PATH it worked. Thanks!

[Updated on: Thu, 05 July 2007 08:49] by Moderator

Report message to a moderator

Re: vzctl restart from crontab [message #14672 is a reply to message #14658] Thu, 05 July 2007 08:48 Go to previous messageGo to next message
Vasily Tarasov is currently offline  Vasily Tarasov
Messages: 1345
Registered: January 2006
Senior Member
Rick or Jonas, can you please create a small article at http://wiki.openvz.org in Troubleshooting section?

Thanks in advance,
Vasily.
Re: vzctl restart from crontab [message #14676 is a reply to message #14672] Thu, 05 July 2007 12:25 Go to previous messageGo to next message
rickb is currently offline  rickb
Messages: 368
Registered: October 2006
Senior Member
Hi Jonas, did you modify the crond PATH in the past on your server?
What distro are you using?

I have never seen the exact problem you described, I offered that idea out of exeperience from when things don't work in cron yet work under a sshd bash shell- usually the path differs and causes the problem when the cron script/app uses relative links.



-------------
Common Terms I post with: http://wiki.openvz.org/Category:Definitions

UBC. Learn it, love it, live it: http://wiki.openvz.org/Proc/user_beancounters
Re: *SOLVED* vzctl restart from crontab [message #14690 is a reply to message #14612] Fri, 06 July 2007 04:17 Go to previous message
jonasb is currently offline  jonasb
Messages: 20
Registered: July 2007
Junior Member
I have not changed the PATH.
Im running CentOS5.
Previous Topic: Multicast between VEs
Next Topic: *SOLVED* Disk quota exceeded
Goto Forum:
  


Current Time: Mon Jul 15 20:56:55 GMT 2024

Total time taken to generate the page: 0.02501 seconds