Good Day Everyone,
Here is the solution to the issue with cron not working with GhettoVCB.sh script. Basically when executing ghettoVCB.sh from this command ./ghettoVCB.sh , the scripts works. However when running a cron job via the crontab file (0 20 * * 1,2,3,4,5 for example), the script doesn't work.
Cause: Apparently cron for some reason can't find vmkfstools binary without using absolute paths.
Solution: edit the ghettoVCB.sh script. There is a the function named ghettoVCB(). Toward the middle there is two references to vmkfstools. Here is the partial code:
ghettoVCB()
{
//Code......................... go toward middle
do
vmkfstools -i "${SOURCE_VMDK}" -d 2gbsparse "$" //Replace vmkstools with /usr/sbin/vmkfstools else vmkfstools -i "$" "$" //Replace vmkstools with /usr/sbin/vmkfstools
fi
done
//New code
do
/usr/sbin/vmkfstools -i "$" -d 2gbsparse "$" //Replaced vmkstools with /usr/sbin/vmkfstools else /usr/sbin/vmkfstools -i "$" "$" //Replaced vmkstools with /usr/sbin/vmkfstools
fi
done
}
Hopefully this will save time for others whom have come across this same issue. I have attached a copy of my working script
Thanks
Stevester
Duplicated post, please refer to :
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at:
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
Duplicated