Find the answer to your Linux question:
Results 1 to 6 of 6
Hello all... Here is my script I would like to run every day at 1615 (4:15pm) rsync -av --exclude=Music --exclude=Virtual_Machines /home/<user> <user>@<server>:/home I have saved it as home/<user>/scripts/desklapsync.sh with perms ...
  1. #1
    Linux Newbie AboveNBeyond's Avatar
    Join Date
    Mar 2007
    Posts
    120

    Am I setting this up for a cron job correctly?

    Hello all...
    Here is my script I would like to run every day at 1615 (4:15pm)

    rsync -av --exclude=Music --exclude=Virtual_Machines /home/<user> <user>@<server>:/home
    I have saved it as home/<user>/scripts/desklapsync.sh with perms set to 644.

    So I would like to have it run as a cron job.
    Here is my crontab...

    15 16 * * * home/<user>/scripts/desklapsync.sh
    Is this all correct?

    And if so, how can I tell if the job ran?

    Thanks.

  2. #2
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    Location
    Texas
    Posts
    1,692
    I'd add a couple things to the script (sh-bang line, FQ binary name, and exit).

    Code:
    #!/bin/bash
    
    /usr/local/bin/rsync -av --exclude=Music --exclude=Virtual_Machines /home/<user> <user>@<server>:/home
    
    exit 0
    Replace '/usr/local/bin' with the correct FQ path to rsync.

    I am presuming you've already tested that this works properly outside of cron...

    Quote Originally Posted by AboveNBeyond
    how can I tell if the job ran?
    Check the cron logs in /var/log. Also, you're putting rsync in verbose mode, so you're going to be getting system email to the account that is running the rsync. (By default stdout/stderr chatter from cron will go to the user's mailbox.) So check with mail.

  3. #3
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    Location
    Texas
    Posts
    1,692
    You're also missing the '/' that should precede /home in the crontab entry.

  4. #4
    Linux Newbie AboveNBeyond's Avatar
    Join Date
    Mar 2007
    Posts
    120
    Thanks Anomie... just a couple more questions...
    1) Does my cron tab entry look correct?
    2) How can I tell if the cron job ran successfully?
    It sends an email, no?

  5. #5
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    Location
    Texas
    Posts
    1,692
    1. No, your crontab entry does not look correct. See my second post above. The path to /home/user is missing the first '/'.

    2. See my first post above. /var/log/cron & check the user's mail (assuming you installed this as a user's crontab).

  6. #6
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    Also, if you're expecting cron to execute your script you should really make it executable (755, subject to which user is running the cron job).

Posting Permissions

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