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
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
Take a look at this thread - http://communities.vmware.com/message/1587207#1587207
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
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
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
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