Koozali.org: home of the SME Server

How to test cron job

CKConsulting

How to test cron job
« on: November 30, 2004, 06:06:21 AM »
I have a backup job in cron.daily.  What command do I use to run the job manualy for testing?

Rick

mbachmann

How to test cron job
« Reply #1 on: November 30, 2004, 09:01:47 AM »
Wich command does cron call? Post the cron entry.

CKConsulting

How to test cron job
« Reply #2 on: November 30, 2004, 02:45:57 PM »
The file is called backup.con I have posted it below.

----------------------------------------
#!/bin/sh
# full and incremental backup script
# created 07 February 2000
# Based on a script by Daniel O'Callaghan <danny@freebsd.org>
# and modified by Gerhard Mourani <gmourani@videotron.ca>

#Change the 5 variables below to fit your computer/backup

COMPUTER=linux                              # name of this computer
DIRECTORIES="/mnt/server1"                        # directoris to backup
BACKUPDIR=/backups/server1/backups              # where to store the backups
TIMEDIR=/backups/server1/last-full                # where to store time of full backup
TAR=/bin/tar                               # name and locaction of tar

#You should not have to change anything below here

PATH=/usr/local/bin:/usr/bin:/bin
DOW=date +%a                    # Day of the week e.g. Mon
DOM=date +%d                    # Date of the Month e.g. 27
DM=date +%d%b                # Date and Month e.g. 27Sep

# On the 1st of the month a permanet full backup is made
# Every Sunday a full backup is made - overwriting last Sundays backup
# The rest of the time an incremental backup is made. Each incremental
# backup overwrites last weeks incremental backup of the same name.
#
# if NEWER = "", then tar backs up all files in the directories
# otherwise it backs up files newer than the NEWER date. NEWER
# gets it date from the file written every Sunday.


# Monthly full backup
if [ $DOM = "01" ]; then
        NEWER=""
        $TAR $NEWER -cf $BACKUPDIR/$COMPUTER-$DM.tar $DIRECTORIES
fi

# Weekly full backup
if [ $DOW = "Sun" ]; then
        NEWER=""
        NOW=date +%d-%b

        # Update full backup date
        echo $NOW > $TIMEDIR/$COMPUTER-full-date
        $TAR $NEWER -cf $BACKUPDIR/$COMPUTER-$DOW.tar $DIRECTORIES

# Make incremental backup - overwrite last weeks
else

        # Get date of last full backup
        NEWER="--newer cat $TIMEDIR/$COMPUTER-full-date"
        $TAR $NEWER -cf $BACKUPDIR/$COMPUTER-$DOW.tar $DIRECTORIES
fi

mbachmann

How to test cron job
« Reply #3 on: November 30, 2004, 04:26:22 PM »
It 'just' calls a tar command. Look at /etc/crontab under

#run parts
02  .....  /etc/cron.daily, from there it is called.

For the usage and syntax of cron/crontab go searching.