Problems with vmware-cmd and cron? Try this solution.

If you do a Google search for Virtual Machine backup utilities, you’ll notice LOTS of people are having weird issues, like “only the first virtual machine gets backed up, but it doesn’t get restarted either”, or “When I run it by hand over SSH, it works!”.

People, the problem there is that cron is just a command scheduler. It does not provide scheduled commands a session environment, like the one ssh gives.

Ergo, the solution is to use the most wonderful tool there is: screen.

Using the package manager of your choice, install the “screen” package. For instance, in Ubuntu / Debian, just issue an apt-get install screen -y

Now, let’s assume your VMware Backup script is located at… /usr/local/sbin/vmware_backup.sh and has +x, then this could the /etc/crontab entry:

10 3    * * *   root    /usr/bin/screen -L -l -d -m -s /bin/bash -S VMBACKUP /usr/local/sbin/vmware_backup.sh

Congrats, now vmware-cmd, rsync and all commands will have a perfectly valid session environment, and everything will work just like as if you’ve run it over ssh.

Optionally, if you want to have log of it’s execution, just add this to /root/.screenrc:

logfile /tmp/VMBACKUP.log.%n

Adapt the path to suit your needs. “man screen” for more details.

Artículos relacionados:

Si te gustó este articulo, ¿ Porque no dejas un comentario a continuación y continuas la conversación, o te suscribes a los feeds y recibes los artículos directamente en tu lector?

Comentarios

No comments yet.

Sorry, the comment form is closed at this time.