Find the answer to your Linux question:
Results 1 to 9 of 9
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Problems with Cron.

    I have a cronjob that I would like to run.

    The file is backup.cron:
    #Other stuff.

    #this is the cronjob for maintaing backup

    * 23 * * mon root rsync -a /mnt/primary/ /mnt/monday/
    * 23 * * tue root rsync -a /mnt/primary/ /mnt/tuesday/
    * 23 * * wed root rsync -a /mnt/primary/ /mnt/wednesday/
    * 23 * * thu root rsync -a /mnt/primary/ /mnt/thursday/
    * 23 * * fri root rsync -a /mnt/primary/ /mnt/friday/
    * 23 * * sat root rsync -a /mnt/primary/ /mnt/sat

    I have run crontab backup.cron and as a result crontab -l produces the file above, however what I want to run does not run. Ideally at 11 PM on every night except sunday it will sync over the contents of the primary disc to the correct backup disk, however it's not.



  2. #2
    Linux Engineer Zelmo's Avatar
    Join Date
    Jan 2006
    Riverton, UT, USA
    I'd suggest checking root's mail first to see if the cron job reports anything.
    Aside from that, two things look suspect:
    1. For rsync, the destination directory does not need a trailing slash (some sources say you must not have a trailing slash).
    2. In the "minutes" column of the crontab, you have an asterisk. Do you really mean to run the job every minute from 11:00 PM to 11:59 PM?
    Stand up and be counted as a Linux user!

  3. #3
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    * 23 * * mon root rsync -a /mnt/primary/ /mnt/monday/
    See man 5 crontab. You're trying to run this once every minute starting at 23:00.

    Not sure if that's the problem, but it is the first thing I'd fix. You also may want to use the fully-qualified path to rsync.

    edit: that'll teach me to keep the page open for awhile before replying.

  4. $spacer_open
  5. #4
    I changed the minutes.

    I'll see if it works, hopefully it will.

    Thanks for the help!

  6. #5
    unfortunately that didn't seem to do the trick.

    This is CentOS if that helps at all.

    Thanks Again!

  7. #6
    Actually, I checked the mail and the main error it gave was:

    /bin/sh: root: command not found

    Do I have the user in the wrong spot?

  8. #7
    In the file you actually use to set cron, remove the word 'root' from all six 'rsync' lines...

  9. #8
    Linux Engineer Zelmo's Avatar
    Join Date
    Jan 2006
    Riverton, UT, USA
    If this is your normal user's crontab, there is no "user" column; that column is only used in the system-wide crontab (/etc/crontab). So, yeah, if your normal user account has the read/write privileges for the backup directory, you can just remove "root" from each line. Or if you really need root to do the backups, use the system crontab.
    Stand up and be counted as a Linux user!

  10. #9

    Linux newbie needs help with cron

    Hi guys

    can anyone tell me how i can check how often cron has stopped and started and where i can get the logs for the stops to see why?

Posting Permissions

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