Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2008
    Location
    Toronto, Canada
    Posts
    2,367

    Unanswered: crontab question #2

    I'd like to do the following:

    - Schedule daily backups during Jan-Apr
    - Schedule weekly backups during May-Dec

    Backups will be scheduled in crontab.


    Is it possible to write a script similar to is_dow posted here [ http://www.dbforums.com/unix-shell-s...-question.html ] that will determine the current month and decide if the job should be run daily or weekly?

    What I can do is to create a file with the required crontab entries and schedule a job to run "crontab <file>" on Jan 1st (with daily backups, etc..) and May 1st (with weekly backups, etc..). This seems to work ok, but I'd like to know if there is a better way to accomplish this?

  2. #2
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    This is the script that crontab calls every day.
    Code:
    this_month=`date +%m`
    if [ $this_month -le 4 ]
    then 
       do_daily_backup
    else
       do_weekly_backup
    fi
    This is the daily backup
    Code:
    #do_daily_backup
      copy all files to tape
    This is the weekly backup

    Code:
    #do weekly backup
    today=`date +%u`   #monday is 1, sunday is 7
    if [ $today -eq "the day I want to do the backup" ]
    then
      copy files to tape
    else
      echo "not today"
    fi
    Last edited by kitaman; 08-03-12 at 14:57.

  3. #3
    Join Date
    Aug 2008
    Location
    Toronto, Canada
    Posts
    2,367
    Thank you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •