LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-06-2009, 09:57 AM   #1
SimonTHK
Member
 
Registered: Sep 2009
Posts: 30

Rep: Reputation: 15
Cron and Rsync


* * * * * sudo rsync -azvv /home/simonthk/Folder1/ /home/simonthk/Folder2

the shown command has been put into a nano file named test2

the I run this command:

sudo crontab -u simonthk test2


I would believe that it would run the Rsync command now each minute, but it doesnt. What am I doing wrong?

Last edited by SimonTHK; 10-06-2009 at 10:05 AM.
 
Old 10-06-2009, 09:59 AM   #2
SimonTHK
Member
 
Registered: Sep 2009
Posts: 30

Original Poster
Rep: Reputation: 15
it tells me: "no such file or directory" when I try to run the cron command
 
Old 10-06-2009, 10:01 AM   #3
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by SimonTHK View Post
* * * * * sudo rsync -azvv /home/simonthk/Folder1/ /home/simonthk/Folder2

the shown command has been put into a nano file named test2

the I run this command:

sudo crontab -u simonthk test


I would believe that it would run the Rsync command now each minute, but it doesnt. What am I doing wrong?

try

Code:
/usr/bin/sudo /usr/bin/rsync -azvv /home/simonthk/Folder1/ /home/simonthk/Folder2

you need full paths if 'PATH' not specified in the crontab.
also run the commands from a command line as that particular user to see how it runs

Last edited by centosboy; 10-06-2009 at 10:34 AM.
 
Old 10-06-2009, 10:02 AM   #4
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by SimonTHK View Post
it tells me: "no such file or directory" when I try to run the cron command
hang on...you said the file is called test2??
but you are assigning the cron from a file called test???
 
Old 10-06-2009, 10:04 AM   #5
SimonTHK
Member
 
Registered: Sep 2009
Posts: 30

Original Poster
Rep: Reputation: 15
the Rsync command:

"su
Quote:
do rsync -azvv /home/simonthk/Folder1/ /home/simonthk/Folder2"
works just fine, the problem is to make the cron job thing work. If thats what you try and help me with, I dont get it
 
Old 10-06-2009, 10:05 AM   #6
SimonTHK
Member
 
Registered: Sep 2009
Posts: 30

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by centosboy View Post
hang on...you said the file is called test2??
but you are assigning the cron from a file called test???

ups I see, that was a misspell in here, I have done it correct in the terminal.
 
Old 10-06-2009, 10:23 AM   #7
SimonTHK
Member
 
Registered: Sep 2009
Posts: 30

Original Poster
Rep: Reputation: 15
this is what it says in my terminal:

Quote:
usage: crontab [-u user] file
crontab [-u user] { -e | -l | -r }
(default operation is replace, per 1003.2)
-e (edit user's crontab)
-l (list user's crontab)
-r (delete user's crontab)
-i (prompt before deleting user's crontab)
simonthk@ubuntu:~$ crontab -u simonthk test2
simonthk@ubuntu:~$ crontab -l
* * * * * sudo rsync -azvv /home/simonthk/Folder1/ /home/simonthk/Folder2
simonthk@ubuntu:~$
for me it seems that I have a cron job running and it is the correct command. Still though it doesnt copy the folder as was my intention, even though it does copy folder if I run the Rsync command itself:
Quote:
sudo rsync -azvv /home/simonthk/Folder1/ /home/simonthk/Folder2
so can anyone see what Im doing wrong?
 
Old 10-06-2009, 10:30 AM   #8
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by SimonTHK View Post
this is what it says in my terminal:



for me it seems that I have a cron job running and it is the correct command. Still though it doesnt copy the folder as was my intention, even though it does copy folder if I run the Rsync command itself:

so can anyone see what Im doing wrong?

look at my previous post regarding paths...
 
Old 10-06-2009, 10:33 AM   #9
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
oh and another thing

Code:
sudo rsync -azvv /home/simonthk/Folder1/ /home/simonthk/Folder2
copies the contents of Folder1 to Folder2.
If you want to copy the whole folder, drop the / at the end of Folder1.
 
Old 10-06-2009, 10:38 AM   #10
SimonTHK
Member
 
Registered: Sep 2009
Posts: 30

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by centosboy View Post
look at my previous post regarding paths...
thank you Cento, but it does no changes.

It now looks like this:
Quote:
* * * * * sudo rsync /usr/bin/sudo /usr/bin/rsync -azvv /home/simonthk/Folder1/ /home/simonthk/Folder2
Though I might found the reason. When I write crontab -l when not in root, I am able to find my job. If I log in as su and write crontab -l there is no jobs.

I know the Rsync command require me to be su, so can this be the problem?

Last edited by SimonTHK; 10-06-2009 at 10:41 AM.
 
Old 10-06-2009, 10:39 AM   #11
SimonTHK
Member
 
Registered: Sep 2009
Posts: 30

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by centosboy View Post
oh and another thing

Code:
sudo rsync -azvv /home/simonthk/Folder1/ /home/simonthk/Folder2
copies the contents of Folder1 to Folder2.
If you want to copy the whole folder, drop the / at the end of Folder1.
I want the contents to be copied but thanks, Ill remember that for another time.
 
Old 10-06-2009, 10:41 AM   #12
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by SimonTHK View Post
thank you Cento, but it does no changes.

It now looks like this:


Though I might found the reason. When I write crontab -l when not in root, I am able to find my job. If I log in as su and write crontab -l there is no jobs.

I know the Rsync command require me to be su, so can this be the problem?
nope

as su , just do crontab -l user

crontab -l as root lists only roots cron jobs

Last edited by centosboy; 10-06-2009 at 10:44 AM.
 
Old 10-06-2009, 10:43 AM   #13
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
can you also check in /var/log/cron for any errors. and make sure crond is actually running
 
Old 10-06-2009, 10:53 AM   #14
SimonTHK
Member
 
Registered: Sep 2009
Posts: 30

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by centosboy View Post
can you also check in /var/log/cron for any errors. and make sure crond is actually running

there is no such log file called cron in that folder. How can I check if its running? Sorry I am still very new
 
Old 10-06-2009, 11:28 AM   #15
SimonTHK
Member
 
Registered: Sep 2009
Posts: 30

Original Poster
Rep: Reputation: 15
someone complaining about crontab in ubuntu, maybe I should try out debian :/

http://www.siriusventures.com/why-i-...b-not-enabled/

cause the problems seems very similar
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 and cron numtre Linux - Software 1 01-08-2009 06:54 AM
Need coaching with RSync and cron configuration on Ubuntu mkenyon2 Linux - Software 4 12-17-2008 03:09 AM
Auto RSYNC Over SSH via Cron? carlosinfl Linux - General 1 09-10-2007 02:12 PM
Cannot execute rsync as a cron job jdaniels73 Linux - Software 2 09-03-2006 05:03 AM
using rsync with cron & pub. key kmitz Fedora 0 01-14-2005 08:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:34 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