I have a script that I wrote to verify on an OS X machine (v 10.7.4) if a volume is up or down. If it goes down, it is supposed to send an email. When I run the script from the command line, it works perfectly and shows me my control volume (DGS_Ima_ASDF_ges_MTL) as being down in the email I receive. However, if I schedule the script in the crontab, it says all my volumes are down, including my control volume, in the email that I receive. Can someone maybe tell me how to fix this. This is my script:
#!/bin/bash
array=("Chatelaine" "DGS_Ima_ASDF_ges_MTL" "FMC_MTL" "GF_MTL" "Holding_Tank_MTL" "LACM_MTL" "LAP_MTL" "actualite" "Loulou" "Loulou_Web" "MQC_MTL" "PS_MTL" "QP_MTL" "Visuels_MTL")
EMAIL_ADDRESSES=here.now@there.com
SAVE_TO=~/Documents/drives_not_mounted
CRONTAB_CONFIG=~/Documents/crontab_paramaters
rm $SAVE_TO
for counter in ${!array[*]}
do
mount | grep ${array[counter]}
if [ $? -ne 0 ]; then
echo "${array[counter]}" >> $SAVE_TO
fi
done
ls ~/Documents | grep drives_not_mounted
if [ $? -eq 0 ]; then
mailx -s "Mounted volumes are down" "$EMAIL_ADDRESSES" < $SAVE_TO
fi
exit;