VMware Cloud Community
Blackbunchie
Contributor
Contributor

Automating A Command

Hi,

Please forgive my ignorance but I am very much a noob with regard to scripting within vsphere/esx. I've been hunting around the web this morning and havent found anything conclusive.

What i am trying to acheive is,

I would like to automate the exceution of this command on an ESX host and also have it run on a shedule.

vmkfstools  -L lunreset /vmfs/devices/disks/t10.F405E46494C45400335366261333D24756E686D2B4F497D4

i'd be really grateful if someone could point me in the right direction.

many thanks

Bunchie

0 Kudos
3 Replies
vmroyale
Immortal
Immortal

Hello.

There is information about using cron to schedule tasks in kb 1033346.

Good Luck!

Brian Atkinson | vExpert | VMTN Moderator | Author of "VCP5-DCV VMware Certified Professional-Data Center Virtualization on vSphere 5.5 Study Guide: VCP-550" | @vmroyale | http://vmroyale.com
0 Kudos
Blackbunchie
Contributor
Contributor

Thanks, i've done some reading on crond, but i'm not having much luck implementing.

Does this look like it would work?

0 0 * * * * vmkfstools -L lunreset /vmfs/devices/disks/t10.F405E46494C45400335366261333D24756E686D2B4F497D4

thanks.

Bunchie

0 Kudos
Blackbunchie
Contributor
Contributor

I've created two files as below. A script with the command I want to run and a crontab file to shedule and execute daily at midnight.
1, script
#/bin/bash
clear
vmkfstools  -L lunreset /vmfs/devices/disks/t10.F405E46494C45400335366261333D24756E686D2B4F497D4
2, crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# run-parts
it seems to have registered ok
Output from crontab -l
0 0 * * * root /etc/customscripts/clearlun
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# run-parts
0 0 * * * root /etc/customscripts/clearlun
Does this all look ok?
cheers
bunchie
0 Kudos