hi guys
i wrote a piece of code to back up my wiki data file from fedora to my windows xp
this script works perfectly if i run it manuallyCode:#!/bin/bash working_directory=/root/scripts/cron source=/root/wiki/ target=wiki.`date '+%y%m%d'`.tar remoteadd=//192.168.198.1/r mountpoint=/root/Rmount/ winuser=administrator mypasswd=password log=/root/scripts/cron/backupwiki.log mount_error=1 copy_error=2 mount_flag=0 copy_flag=0 cd $working_directory echo "Hello-------------------------------------------`date '+%y%m%d'`">>$log mount.cifs $remoteadd $mountpoint -o user=$winuser%$mypasswd>>$log mount_flag=`echo $?` echo "$mount_flag">>$log if [ $mount_flag -eq 0 ];then echo "Mount successfully" else tail -2 backupwiki.log echo "bad mount">>$log echo "BadBye------------------------------------------`date '+%y%m%d'`">>$log exit $mount_error fi tar -czvf $target $source&&cp $target $mountpoint copy_flag=`echo $?` if [ $copy_flag -eq 0 ];then rm -rf $target>>$log umount $mountpoint>>$log echo "Backup successfully" echo "GoodBye-----------------------------------------`date '+%y%m%d'`">>$log exit 0 else umount $mountpoint>>$log rm -rf $target>>$log echo "Copy problem" echo "Copy problem">>$log echo "BadBye------------------------------------------`date '+%y%m%d'`">>$log exit $copy_error fi
but it failed if run by cron job (as root user)
Code:[root@MYSERVER cron]# crontab -l 00 */1 * * * rdate -s time-b.nist.gov 37 13 * * * sh /root/scripts/cron/backupwiki.sh
the error log is following
Code:Hello-------------------------------------------080907 127 bad mount BadBye------------------------------------------080907
the file structure is
anyone has any idea about error code 127 for mount.cifs?Code:[root@MYSERVER cron]# ls -l 8 -rwxrwxrwx 1 root root 236 09-07 13:37 backupwiki.log -rwxrwxrwx 1 root root 1199 09-07 13:00 backupwiki.sh
i spend couple of hours to figure out but just have no clue at all.......
plz give a hand on this
thanks and regard


Reply With Quote
