I am a bit baffled here, and not really sure how to debug this. I have a self-written bash script, that checks if a samba share is active, and if not, sends me an email.
Script is in /root/SKRIPTS/, permission looks like this:
-rwxr-xr-x 1 root wheel 281 Nov 8 08:54 test_samba_shares.sh -rwx------ 1 root wheel 39 Nov 7 13:56 smbclient.cred
Content of the .sh script is this:
smbclient -L 10.0.0.1 -A /root/SKRIPTS/smbclient.cred | grep -q Backup if [ $ ? -eq 0 ] then echo "Backup_* mounted, nothing to do" else echo "Subject: Samba has failed" | /usr/sbin/sendmail -v email@example.com fi return 1;
/etc/crontab looks like this (entry only)
10 1 * * * root /root/SKRIPTS/test_samba_shares.sh
The thing is, if I, as root, run this, it works flawlessly. But every night I get an email that samba has failed, indicating that the cron script somehow trips into the else path. How can this be? Am I missing something obvious here? What would be the best way to debug this?
Thanks for your help