[SOLVED] rsync execution issue with crontab - Have given full path to rsync too!!
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
rsync execution issue with crontab - Have given full path to rsync too!!
I have a tiny shell script to rsync files between two servers and remove the source files.
This script works fine, when it has been initiated manually or even when the rsync command is executed on the command line.
But the same script doesn't work, when I try to automate it through crontab.
Script looks like this @ /mnt/xyz/folder/rsync.sh:
chown abc.abc /mnt/source/folder/ -R
sudo -u abc /usr/bin/rsync -azvH --remove-source-files /mnt/source/folder/ abc@destination-ip:/mnt/destinationfolder/
I am using 'abc' user to execute this rsync, instead of root, as root login to servers are restricted in all of our servers, by us.
As I mentioned earlier, manual execution works like charm!!
When this rsync.sh is initiated through crontab, it runs the first command(chown abc.abc ...) perfectly without any issues. But the second line is not at all executed, and there is no log entry i can find at /mnt/xyz/folder/rsync.log
Crontab entry would like this:
*/10 * * * * /mnt/xyz/folder/rsync.sh >> /mnt/xyz/folder/rsync.log
Any help would be appreciated.
And, if i am doing something wrong in my script or crontab, please guide me in right path.
Also, if any more information needed from me, i would do that.
Last edited by Prabagaran; 04-12-2011 at 07:12 AM.
1. I don't see any mail to root & it will be great, if you could let me know how to check crontab log.
When I checked for /var/log/messages, no entries regarding crontab/rsync is found.
Also under /var/spool/mail/root, no logs i could find.
2. ps aux |grep rsync gave me this:
root 11024 0.0 0.0 6064 612 pts/1 R+ 04:36 0:00 grep rsync
3. I have key-authentication for abc user.
4. Cron runs as root. Also, in the script, first line is executed as root(so that the file permissions could be changed,otherwise not). And the second line(rsync) will be executed as 'abc' user.
Also, as I mentioned in my initial post, the whole script is running fine, if it is executed in command line, manually like this:
]#sudo -u abc /usr/bin/rsync -azvH --remove-source-files /mnt/source/folder/ abc@destination-ip:/mnt/destinationfolder/
Any more information needed from me, would like to share.