The musings of an IT Consultant

Feb 8 2009   12:29AM GMT

Scheduling jobs in ESXi the Easy Way



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

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

Leave a comment:

Binderer  |   Mar 12, 2009  12:57 PM (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:27 PM (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:22 AM (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
[CODE]c:puttyplink.exe backup@10.10.10.5 -pw backup “nohup /././. “[/CODE]
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:
[CODE]/vmfs/volumes/b03bf723-44c925a1 $ ./ghettoVCB.sh vmbackuplist
This script needs to be executed by “root”![/CODE]
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:39 PM (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:30 AM (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:53 PM (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:09 PM (GMT)

Hallo again Raj,

any Results on our issue ?

Thanks


 

Rparamount  |   Mar 23, 2009  1:25 PM (GMT)

Hi Binderer, please post your questions [A href="http://communities.vmware.com/docs/DOC-8760"]here for William Lam’s script.[/A] They should be able to help you there as I am not sure of the answer. Thanks!

-RP


 

Mcargy08  |   Mar 26, 2009  10:14 PM (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 root@192.168.1.113 -pw password “nohup ./vmfs/volumes/datastore2/ghetto.sh /vmfs/volumes/datastore2/vmwarebackups > /vmfs/volumes/datastore2/backuplog.txt &”


 

Flatpack  |   Apr 9, 2009  7:33 AM (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:17 AM (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:46 PM (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 [A href="http://communities.vmware.com/docs/DOC-8760"]link[/A].


 

NexusGuy59  |   Dec 10, 2009  5:39 PM (GMT)

I have a question, no one has been able to answer.I run ghettoVCB via cron on my ESXi server and it started running this morning I noticed it is still running. Now I know that it failed because I had snapshots already present however my log file is filling up and it’s not letting me stop the process that is running. I thought it would be ghettoVCB, however it is not ghettoVCB after ps|grep ghettoVCB low and behold it doesn’t show up in the output. So I need to know and identify which process is still running the process and kill it, anyone have any ideas at all?

Thanks,