LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-25-2010, 08:17 AM   #1
schwabeNiu
LQ Newbie
 
Registered: Nov 2010
Posts: 2

Rep: Reputation: 0
problem about using crond to execute rsync


Hi everyone, I have one question:

I would like to execute a shell script using crond per five minutes. my crontab file is like this

*/5 * * * * /root/cron_shell.sh > /dev/null
#

shell script is like this

cron_shell.sh

#!/bin/bash
date > /root/share/test
cat /root/share/test
/usr/bin/rsync -aze ssh --delete /root/share uname@xxx.xxx.xxx.xxx:/home/uname/

I got correct result for file test(for every five minutes, it is updated), but rsync could not be executed. However, I execute cron_shell.sh manually, it is OK. Thank you all for reading this question.

Last edited by schwabeNiu; 11-25-2010 at 08:21 AM.
 
Old 11-25-2010, 08:19 AM   #2
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
Often when this sort of thing happens (assuming not a permissions problem), it is due to the crond daemon running with only a very minimal ENVironment setup. Try in your script, giving full absolute paths to any binary or commands you are executing (cat, rsync, date, etc..) and see if that fixes it?
 
Old 11-25-2010, 08:27 AM   #3
schwabeNiu
LQ Newbie
 
Registered: Nov 2010
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by GrapefruiTgirl View Post
Often when this sort of thing happens (assuming not a permissions problem), it is due to the crond daemon running with only a very minimal ENVironment setup. Try in your script, giving full absolute paths to any binary or commands you are executing (cat, rsync, date, etc..) and see if that fixes it?
Thank you for your reply.
I tried absolute path, but no change. This is script.
And I use top to monitor the crond, when the script being executed, top shows sh <defunct>.
cron_shell.sh

#!/bin/bash
/bin/date > /root/share/test
/bin/cat /root/share/test
/usr/bin/rsync -aze ssh --delete /root/share uname@xxx.xxx.xxx.xxx:/home/uname/
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
rsync ssh - how to execute shell commands on server banjer Linux - Newbie 4 11-04-2009 02:01 PM
/sbin/service crond unable to start - gives permission error on /usr/sbin/crond mgervacio Linux - Newbie 6 07-16-2008 01:03 PM
Cannot execute rsync as a cron job jdaniels73 Linux - Software 2 09-03-2006 05:03 AM
crond problem branden_burger Linux - General 3 03-25-2005 05:03 PM
problem running crond wakeupatul Linux - General 1 04-20-2004 01:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration