Find the answer to your Linux question:
Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By gabolander
Hi! Im using CentOS 5 on my server and im trying to make a crontab job to backup my disk with rsync, but i wont run the script. the script ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2011
    Posts
    4

    I cant get crontab to execute my rsync script....


    Hi!

    Im using CentOS 5 on my server and im trying to make a crontab job to backup my disk with rsync, but i wont run the script.

    the script location is /root/rsync-shell.sh and looks like:
    ------------

    #!/bin/bash
    rsync -avru --progress --delete --exclude="/mnt/Backup" --exclude="/sys" --exclude="/dev" --exclude="/proc" / /mnt/Backup

    ------------

    in my /etc/crontab i've put the line:

    SHELL=/bin/bash
    PATH=/sbin:/bin:/usr/sbin:/usr/bin
    MAILTO=
    HOME=/

    # run-parts
    01 * * * * root run-parts /etc/cron.hourly
    02 4 * * * root run-parts /etc/cron.daily
    22 4 * * 0 root run-parts /etc/cron.weekly
    42 4 1 * * root run-parts /etc/cron.monthly

    0 22 * * * /root/rsync-shell.sh

    When i run the script in terminal it works fine but crontab wont execute it...

    Anyone got an idea ?

    BR /Jim

  2. #2
    Trusted Penguin Dapper Dan's Avatar
    Join Date
    Oct 2004
    Location
    The Sovereign State of South Carolina
    Posts
    4,630
    I'm no crontab expert but have had problems getting scripts to run properly via crontab as well. A "work-around" I've found that works in some cases is to run the script in a terminal.
    Code:
    #!/bin/bash
    xterm -e rsync -avru --progress --delete --exclude="/mnt/Backup" --exclude="/sys" --exclude="/dev" --exclude="/proc" / /mnt/Backup
    There's probably a better way to do it. Hopefully someone will come along with that information.
    Linux Mint + IceWM Registered: #371367 New Members: click here

  3. #3
    Just Joined!
    Join Date
    Sep 2008
    Posts
    22

    Talking

    Quote Originally Posted by Theatre View Post
    Hi!

    Im using CentOS 5 on my server and im trying
    ......
    in my /etc/crontab i've put the line:
    ......

    # run-parts
    01 * * * * root run-parts /etc/cron.hourly
    02 4 * * * root run-parts /etc/cron.daily
    22 4 * * 0 root run-parts /etc/cron.weekly
    42 4 1 * * root run-parts /etc/cron.monthly

    0 22 * * * /root/rsync-shell.sh
    Hi there Theatre

    The problem is that user that runs cron command is missing.

    So, change the line in /etc/crontab to read

    Code:
    0 22 * * * root /root/rsync-shell.sh
    then restart cron service with:
    Code:
    service crond restart
    and you will see it working

    In /etc/crontab, you must specify user that crontab will run tasks with. While if you want to insert a specific cron job in the user spool, U can use "crontab -e ". In this environment you don't have to specify user because it will be scheduled with user the ran command "crontab -e". But in /etc/crontab syntax, the user that performs a scheduled job, is mandatory.

    Regards,
    Dapper Dan likes this.

  4. #4
    Just Joined!
    Join Date
    Jun 2007
    Posts
    3
    Quote Originally Posted by Theatre View Post
    Hi!



    in my /etc/crontab i've put the line:

    SHELL=/bin/bash
    PATH=/sbin:/bin:/usr/sbin:/usr/bin
    MAILTO=
    HOME=/

    # run-parts
    01 * * * * root run-parts /etc/cron.hourly
    02 4 * * * root run-parts /etc/cron.daily
    22 4 * * 0 root run-parts /etc/cron.weekly
    42 4 1 * * root run-parts /etc/cron.monthly

    0 22 * * * /root/rsync-shell.sh



    Anyone got an idea ?

    BR /Jim
    /etc/crontab file sintax is different ...
    You miss the user name who run this script, the correct sintax is:
    0 22 * * * root /root/rsync-shell.sh

    Best regards,
    Gyula

Posting Permissions

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