Scheduling jobs in ESXi the Easy Way - The musings of an IT Consultant

The musings of an IT Consultant

Feb 8 2009   12:29AM GMT

Scheduling jobs in ESXi the Easy Way



Posted by: Raj Perumal
backups, virtual machine backups, VMware backups, backup ESXi, backups VMware ESXi, VMware ESXi, VMware ESX, backup free vmware, VCB, backup without VCB, backup script, ghettoVCB, ghetto VCB, ghettoVCB.sh, William Lam, lamw, http://communities.vmware.com/docs/DOC-8760, how to implement ghettoVCB, how to backup virtual machine, how to backup ESXi, how to backup ESX, how to backup VMware, file level backup, virtual machine level backup, putty, plink, NFS, Windows services for Unix 3.5, Allegro NFS, schedule ESXi ghettoVCB.sh, schedule jobs in ESXi, cron, crond, crontab, cron jobs, how to backup virtual machines

So continued from my previous blogs, I wanted to discuss scheduling jobs in ESXi. Due to the way ESXi is made, you cannot edit the cron jobs and expect them to still be there with their changes past a reboot. Rebooting an ESXi server clears the cron jobs. The cron jobs reset back to their default settings.

In my last blog post I spoke of a program called Plink. Plink is a command line interface to Putty. This allows us to connect to an SSH session from the command line. This can be leveraged using batch scripting and windows scheduled tasks to schedule ESXi jobs.

For my example I will show you how to schedule the ghettoVCB.sh script I spoke about in my last blog entry. Please see my detailed instructions on how to do this in my blog post here.

-RP

Comment on this Post


You must be logged-in to post a comment. Log-in/Register

Binderer  |   Mar 12 2009   12:57PM GMT

I have a quastion about login.
Is it possible to start the BAT file with user other than “root” ? What schould i configure auf dem ESXi für permissions?
Thanks a lot!


 

Rparamount  |   Mar 12 2009   2:27PM GMT

Hi Binderer, yes you can use whatever username you desire and then su to root after you’ve logged in. That would work. The downside of this file is that the password is stored in this plain text batch file.

-RP


 

Binderer  |   Mar 13 2009   10:22AM GMT

Hi Raj and 10x for your answer.

I created a user (useradd backup) and setted the password to backup (passwd backup). So I have now my VCB.bat looking this way

c:puttyplink.exe  <a href="mailto:backup@10.10.10.5" title="mailto:backup@10.10.10.5">backup at 10.10.10.5</a> -pw backup “nohup /././. “

But i do not get the Script running :(
If I logon to the Putty-Console with user: backup and run the script manually I get the Message:

/vmfs/volumes/b03bf723-44c925a1 $ ./ghettoVCB.sh vmbackuplist
This script needs to be executed by “root”!

What am I doing wrong ?
In my userlist is “backup:x:503:503:Linux User,,,:/home/backup:/bin/ash”. I have set also the execute/owner right over the ghettoVCB.sh but no changes.

Should i really su to root to execute the VCB.sh ? How can I do this in my VCB.bat ?
Thanks for your help. We really appreciate that!

Best Regards,
Genov


 

Rparamount  |   Mar 14 2009   4:39PM GMT

Unfortunately Binderer, I’m not sure what the issue is as I never tried to configure it that way before. I would post on William Lam’s site where his script is posted which I linked to in my blog post. He should be able to help you out better than I can.

However if I do hear of the answer I will let you know.

-Cheers, RP


 

Yeled1976  |   Mar 15 2009   11:30AM GMT

Hi
i am trying to schedule the task to run but with no success.
if i run the script from the console of the esxi i have no problem.
if i run it from the plink command it will just move a line down and create an empty backuplog.txt in the folder.
do you have any idea what i should do next?
in addition, when i run the script from the server itself and would like to stop the backup.
should i “ps” and see where ash process is running and just kill it?
thanks


 

Rparamount  |   Mar 15 2009   5:53PM GMT

Hi Yeled1976, try removing the pipe to the backuplog.txt and see how that goes for you. I believe that text file will be empty unless there are any errors that appear.

As for cancelling it, you can kill the process like you mentioned and then you also have to connect to your ESXi server with the VMware client and delete the snapshot that was created by the script. That should do it.

-RP


 

Binderer  |   Mar 23 2009   12:09PM GMT

Hallo again Raj,

any Results on our issue ?

Thanks


 

Rparamount  |   Mar 23 2009   1:25PM GMT

Hi Binderer, please post your questions here for William Lam’s script. They should be able to help you there as I am not sure of the answer. Thanks!

-RP


 

Mcargy08  |   Mar 26 2009   10:14PM GMT

Hi Raj,

I tried to run the batch file but it doesn’t do anything. Like yield said, it will work on the ESXi console but not on windows. Is there something wrong that were doing?

here’s my batch file

c:plink.exe  <a href="mailto:root@192.168.1.113" title="mailto:root@192.168.1.113">root at 192.168.1.113</a> -pw password “nohup ./vmfs/volumes/datastore2/ghetto.sh /vmfs/volumes/datastore2/vmwarebackups > /vmfs/volumes/datastore2/backuplog.txt &”


 

Flatpack  |   Apr 9 2009   7:33AM GMT

Hi Raj

Thanks for the very useful post :-)

However, I am experiencing the same issues as other people on the posts.

I’ve copied the plink information for the scheduled task and the task runs, but nothing happens, and I get the 0 byte backup log file

The commands run fine on the server, just not remotely

Where should I start looking ?

Thanks
Simon


 

Mcargy08  |   Apr 23 2009   1:17AM GMT

Hi RP,

Can you advise us with the issues we are having when running the command using plink? It doesnt seem to work.

Thanks,


 

Raj Perumal  |   Apr 23 2009   5:46PM GMT

Hi guys, unfortunately I’m not sure what the answer is. Please direct your questions to William Lam’s posting in the VMware Communities. That’s where you should be able to find the answers you’re looking for. You can find it here at this link.