can't load module sbp2 when running script from cron
Hi!
I use a wrapper-script around rsnapshot to handle my backups, which I
have attached. When run from the terminal it works great, but when run
from cron it chokes because it can't load module sbp2. The error code I
get from modprobe is 127 if that means anything to anyone.
Does anyone have any idea why it would work from the terminal but not
from cron?
regards
Andreas Berglund
#!/bin/sh
# Wrapper script around rsnapshot to deal with the fact that the backup-media
# is removable
backup_location=/media/backup
# load firewire harddrive module
err_msg=$(modprobe sbp2)
ret=$?
if [ "$ret" -ne 0 ]
then
logger -s -t backup-script "user = `whoami`, \$ret = $ret"
logger -t backup-script -p cron.err "Failed backup at $(date): Couldn't load sbp2 module"
logger -t backup-script -p cron.err "Failed backup at $(date): $err_msg"
exit 1
fi
# allow time for udev to create device file before we try to mount
sleep 2
# See if $backup_location is mounted
grep $backup_location /etc/mtab > /dev/null
# if return value of grep is not 0 then $backup_location is not mounted
if [ $? -ne 0 ]
then
err_msg=$(mount $backup_location)
fi
# Mount failed
if [ $? -ne 0 ]
then
logger -t backup-script -p cron.err "Failed backup at $(date): Mount failed"
logger -t backup-script -p cron.err "Failed backup at $(date): $err_msg"
exit 2
fi
if [ -e $backup_location/backup.lock ]
then
rsnapshot weekly
else
logger -t backup-script -p cron.err "Failed backup at $(date): Lockfile missing, probably wrong media"
fi
logger -t backup-script -p cron.err "Succesful backup at $(date)"
umount $backup_location
rmmod sbp2
Reply to: