VMware Cloud Community
Vmotioner
Contributor
Contributor
Jump to solution

Cron Job via VMA 4.1

I'm trying to setup a cron job on vma 4.1 using lamw's hostOperations.pl script but can't get the script to work without having to pass credentials. If I use the vifptarget -s <vc servername> on the command line and the run the hostOperations.pl script without credentials it works fine.

I'm suspecting the problem is the cron environment...I'm running 2 separate commands in the cron job 1 minute apart.

30 12 25 01 * root vifptarget -s servername

31 12 25 01 * root hostOperations.pl --server <servername> --hostfile <hostfile> --operation exi_maint

My scripting knowledge is limited....is there a way to combine these 2 commands in a single script file that I could call from cron so that the environment is the same for both commands

Thanks

VMotioner

Tags (3)
Reply
0 Kudos
1 Solution

Accepted Solutions
lamw
Community Manager
Community Manager
Jump to solution

Take a look at this blog post - http://www.virtuallyghetto.com/2011/01/how-to-automate-cron-vi-fastpass.html, it goes into more details. I suspect you're missing the LD_SHARED_LIBRARY path for shared libs

View solution in original post

Reply
0 Kudos
5 Replies
lamw
Community Manager
Community Manager
Jump to solution

Vmotioner
Contributor
Contributor
Jump to solution

Thanks again

I just created a small sh script that included these 2 commands and scheduled it via cron and everything worked just fine. No credentials required.

#!/bin/sh

source /opt/vmware/vma/bin/vifptarget -s targethost

/usr/bin/hostOperations.pl --server VChostname --hostfile hostlist.txt --operation ent_maint

VMotioner

Reply
0 Kudos
Vmotioner
Contributor
Contributor
Jump to solution

Hi,

I just noticed that if I don't run hostOperations.pl at least once on the command line that it will not initiate maintenance mode via Cron job. I tried 2 ways....

1 - .sh script that runs source /opt/vmware/vma/bin/vifptarget -s servername and then hostOperations.pl

2 - added $command='source /opt/vmware/vma/bin/vifptarget -s servername' directly into the hostOperations.pl script.

Same issue in both....I tried everything I could think of but no luck...

Thanks

VMotioner

Reply
0 Kudos
lamw
Community Manager
Community Manager
Jump to solution

Take a look at this blog post - http://www.virtuallyghetto.com/2011/01/how-to-automate-cron-vi-fastpass.html, it goes into more details. I suspect you're missing the LD_SHARED_LIBRARY path for shared libs

Reply
0 Kudos
Vmotioner
Contributor
Contributor
Jump to solution

Thanks William,

Looks like that was the problem, I'll know for sure tomorrow morning, I've scheduled a few tasks overnight.

For other people reading this here is the info:

I added LD_LIBRARY_PATH=:/opt/vmware/vma/lib64:/opt/vmware/vma/lib to the /etc/crontab file

Restarted the crond process

service crond restart

Just a side note that I am doing all this logged in as root and not as vi-admin.

Cheers,

VMotioner

Reply
0 Kudos