Results 1 to 4 of 4
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.
- 09-10-2011 #1Just 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
- 09-10-2011 #2
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.
There's probably a better way to do it. Hopefully someone will come along with that information.Code:#!/bin/bash xterm -e rsync -avru --progress --delete --exclude="/mnt/Backup" --exclude="/sys" --exclude="/dev" --exclude="/proc" / /mnt/Backup
- 09-11-2011 #3Just Joined!
- Join Date
- Sep 2008
- Posts
- 22
Hi there Theatre
The problem is that user that runs cron command is missing.
So, change the line in /etc/crontab to read
then restart cron service with:Code:0 22 * * * root /root/rsync-shell.sh
and you will see it workingCode:service crond restart

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,
- 09-11-2011 #4Just Joined!
- Join Date
- Jun 2007
- Posts
- 3


1Likes
Reply With Quote

