Page 1 of 1

2nd cron job can't find script

Posted: Tue Mar 15, 2016 5:54 am
by badams_ios
I can now manually run a backup to a network share. Works GREAT!

What I want ultimately is to run one cron job every month to backup everything, and a second cron job to backup what's changed once a week.

A cron job to backup monthly works fine. When I run the second cron job it says it can't find the script in the script directory. Dag gummit it's there, though!

Re: 2nd cron job can't find script

Posted: Tue Mar 15, 2016 4:23 pm
by TeraByte Support(PP)
When you say the script is there, is that on the installed system ("scripts" folder of the IFL installation) or the "scripts" folder when rebooted to the IFL job (/tbu/scripts)? You may just need to run makeGRUB and Create & Install the files again so they are up to date.

Re: 2nd cron job can't find script

Posted: Tue Mar 15, 2016 7:34 pm
by badams_ios
If I run makeGRUB again, won't it over write the existing script that's in there?

Re: 2nd cron job can't find script

Posted: Tue Mar 15, 2016 7:58 pm
by TeraByte Support(PP)
That scripts that are in the IFL installation's "script" folder are included in the build when you run makeGRUB. It's recreating the files used by GRUB for booting.

For example, if you have "myscript1" in the "scripts" folder and run makeGRUB to create and install the booting files and then want to add "myscript2" you would need to put "myscript2" into the "scripts" folder and then run makeGRUB again to create and install the booting files. Both "myscript1" and "myscript2" will then be included in the booting files (assuming "myscript1" still exists in the "scripts" folder). Basically, you want your current scripts (those being used) in the "scripts" folder of your IFL installation so they get included.

Re: 2nd cron job can't find script

Posted: Tue Mar 15, 2016 8:44 pm
by badams_ios
And the cron job itself will tell IFL which script to run?

Re: 2nd cron job can't find script

Posted: Tue Mar 15, 2016 10:44 pm
by TeraByte Support(PP)
Correct. The script name is passed as part of the cron job command. For example (from the KB article) the script "myscript" would be run by the cron job: 30 5 * * Sun root /usr/local/bin/iflreboot myscript

This works the same as if you ran iflreboot manually and specified a script to run. The script specified has to exist in the IFL booting files, though, or it won't be found.

Re: 2nd cron job can't find script

Posted: Wed Mar 16, 2016 2:58 am
by badams_ios
Excellent, thanks. And if I want this machine to make a full backup quarterly and a differential monthly. I'll have to understand #! bash scripting, correct?

As in this kind of stuff?

error_exit() {
echo `date`
exit 1
}

do_ifl_error() {
if [ ! "$iflerror" = "0" ]; then
echo "Image command $i failed with error code $iflerror"
total_iflerror=1
else
echo "Image command $i completed without error"
fi
}

##############################################################################

## start time stamp
echo `date`

## check for SMB mount program (smbmount or mount.cifs)
if [ "$protocol" = "smbfs" ]; then
if [ ! -x /usr/bin/smbmount ]
then echo "/usr/bin/smbmount not found, or not executable"
error_exit
fi
elif [ "$protocol" = "cifs" ]; then
if [ ! -x /sbin/mount.cifs ]
then echo "/sbin/mount.cifs not found, or not executable"
error_exit
fi
else
echo "No valid protocol selected"
error_exit
fi

## check for SMB umount program
if [ "$protocol" = "smbfs" ]; then
if [ ! -x /usr/bin/smbumount ]
then echo "/usr/bin/smbumount not found, or not executable"
error_exit
fi
else
umountcifspath=""
if [ -x /sbin/umount.cifs ]; then
umountcifspath="/sbin/umount.cifs"
elif [ -x /bin/umount ]; then
umountcifspath="/bin/umount"
else
echo "both /sbin/umount.cifs and /bin/umount not found, or not executable"
error_exit
fi
fi
echo "Using the $protocol SMB protocol"

## check that mount point exists
if [ ! -d $mountpoint ]
then echo "mount point $mountpoint does not exist, or is not a directory"
error_exit
fi

## check if mount point already in use
mountpoint $mountpoint > /dev/null
if [ "$?" = "0" ]
then echo "mount point $mountpoint already in use"
error_exit
fi

## check if mount point is empty
am=`ls $mountpoint`
if [ -n "$am" ]
then echo "mount directory $mountpoint not empty"
error_exit
fi

## check if IFL path is valid and is executable
if [ ! -x $IFLpath ]
then echo "$IFLpath not found, or not executable"
error_exit
fi

## mount the share
if [ "$protocol" = "smbfs" ]; then
smbmount //$server/"$share" $mountpoint $mountoptions
else
/sbin/mount.cifs //$server/"$share" $mountpoint $mountoptions
fi
if [ ! "$?" = "0" ]
then echo "Failed to mount //$server/$share at $mountpoint"
error_exit
else
echo "Mounted //$server/$share at $mountpoint"
fi

## run the IFL command(s)
total_iflerror=0
echo "Number of image commands: $number_image_commands"
if [ ! "$number_image_commands" = "0" ]; then
for i in `seq 1 $number_image_commands`
do
echo
echo "Image command $i: ${iflmessage[$i]}"
echo "$IFLpath ${iflcmd1[$i]} ${iflcmd2[$i]} ${iflcmd3[$i]}"
if [ "$redirectnull" = "y" ]; then
$IFLpath ${iflcmd1[$i]} ${iflcmd2[$i]} ${iflcmd3[$i]} > /dev/null
else
$IFLpath ${iflcmd1[$i]} ${iflcmd2[$i]} ${iflcmd3[$i]}
fi
iflerror=$?
do_ifl_error
done
echo
fi

## unmount the share
sleep 1
for i in `seq 1 10`
do
if [ "$protocol" = "smbfs" ]; then
smbumount $mountpoint
else
$umountcifspath $mountpoint
fi
if [ ! "$?" = "0" ]
then echo "Attempt $i: Failed to unmount //$server/$share from $mountpoint"
if [ "$i" = "10" ]; then
error_exit
else
sleep 2
fi
else
echo "Unmounted //$server/$share from $mountpoint"
if [ "$total_iflerror" = "0" ]
then echo `date`
exit 0
else
error_exit
fi
fi
done

Re: 2nd cron job can't find script

Posted: Wed Mar 16, 2016 6:41 pm
by TeraByte Support(PP)
Some scripting would probably be necessary. Depending on your goals you might get by with something simple (backup name/method based on month, for example) or even several different cron jobs (monthly or monthly/quarterly).