2nd cron job can't find script

User discussion and information resource forum for scripting of TeraByte products using script lanugages such as TBScript, VBScript, Batch Files, and more.
Post Reply
badams_ios
Posts: 39
Joined: Wed May 23, 2012 6:53 pm
Location: Oakdale, Ca
Contact:

2nd cron job can't find script

Post 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!
TeraByte Support(PP)
Posts: 1506
Joined: Fri Aug 12, 2011 12:51 am

Re: 2nd cron job can't find script

Post 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.
Paul Purviance
TeraByte Support
badams_ios
Posts: 39
Joined: Wed May 23, 2012 6:53 pm
Location: Oakdale, Ca
Contact:

Re: 2nd cron job can't find script

Post by badams_ios »

If I run makeGRUB again, won't it over write the existing script that's in there?
TeraByte Support(PP)
Posts: 1506
Joined: Fri Aug 12, 2011 12:51 am

Re: 2nd cron job can't find script

Post 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.
Paul Purviance
TeraByte Support
badams_ios
Posts: 39
Joined: Wed May 23, 2012 6:53 pm
Location: Oakdale, Ca
Contact:

Re: 2nd cron job can't find script

Post by badams_ios »

And the cron job itself will tell IFL which script to run?
TeraByte Support(PP)
Posts: 1506
Joined: Fri Aug 12, 2011 12:51 am

Re: 2nd cron job can't find script

Post 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.
Paul Purviance
TeraByte Support
badams_ios
Posts: 39
Joined: Wed May 23, 2012 6:53 pm
Location: Oakdale, Ca
Contact:

Re: 2nd cron job can't find script

Post 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
TeraByte Support(PP)
Posts: 1506
Joined: Fri Aug 12, 2011 12:51 am

Re: 2nd cron job can't find script

Post 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).
Paul Purviance
TeraByte Support
Post Reply