LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 02-12-2014, 04:04 AM   #1
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,477

Rep: Reputation: 87
Rsync command to/from CIFS share does not work in cron, works in terminal?


Hi guys

I've got the following rsync command to sync files to and from CIFS shares hosted on a Windows 8 box:

To rsync from a CIFS share on Windows 8, in the term, I do

Code:
/usr/bin/rsync -avz --progress --no-whole-file /mnt/remote_software/* /home/earth/software/.
To rsync to a CIFS share on Windows 8, in the term, I do

Code:
/usr/bin/rsync -avz --progress --no-whole-file /home/earth/software/* /mnt/remote_software/.
I mount the above CIFS share via this command (192.168.1.1 being my Windows 8 fileserver) - the share's name is "software" on the Windows machine.

Code:
mount -t cifs //192.168.1.1/software /mnt/remote_software -o username=myname,password=mypass
The above works fine, I can sync files in both directions no problem, browse the share, save new files to it, and read files from this CIFS partition while the files are actually on the Windows box.

However, as soon as I try to touch this share from an rsync-spawned cron, rsync does not work.

My crontab looks like this:
Code:
30 00 * * * sh -f /root/do_backup.sh > errors.txt 2>&1
where do_backup.sh is

Code:
/usr/bin/rsync -avz --progress --no-whole-file /mnt/remote_software/* /home/earth/software/.
Permissions on do_backup.sh are -rwxr-xr-x - eg. executable for all.

E. g. the command I pass from the cron calls do_backup.sh - if I do

Code:
sh -f /root/do_backup.sh
while in a terminal session, it works fine. The files are rsynced from the CIFS share (actually on my Windows machine) to my local Linux machine's /home/earth/software directory.

If cron calls sh -f /root/do_backup.sh rsync cannot see the /mnt/remote_software CIFS share, and the rsync fails.

Errors.txt then contains

Code:
sending incremental file list
rsync: link_stat "/mnt/remote_software/*" failed: No such file or directory (2)
If rsync is run via cron on a CIFS share, it simply does NOT work.

When in the terminal, I run the manual rsync command while logged in as root.

I'm on Centos 6

Any ideas as to why stuff spawned in cron (running as root, correct?) cannot see CIFS shares?

To test I also put a df -mh > mounts.txt into the crontab a minute before the rsync script's start, and mounts.txt clearly contains

Code:
//192.168.1.1/software/                  1.9T  1.3T  601G 68% /mnt/remote/software
which means at cron level, "df" CAN see the share and enumerate it, return its size, etc. - yet the rsync that runs 60 seconds later can't?

Any ideas what is going on and how to fix it?

Thanks!

Last edited by rylan76; 02-12-2014 at 04:05 AM.
 
Old 02-12-2014, 05:37 AM   #2
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,346

Rep: Reputation: 127Reputation: 127
I think the problem is the wildcard '*', it is read literally.
To test that, remove the '*' and add a directory instead.
 
Old 02-12-2014, 08:53 AM   #3
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,477

Original Poster
Rep: Reputation: 87
Hi

Thanks of the reply!

Ok I'll try to remove the trailing * and . and see what happens...

Thanks again
 
Old 02-17-2014, 02:34 AM   #4
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,477

Original Poster
Rep: Reputation: 87
That was the solution! I removed the * as trailing character for the source rsync specification and removed . as trailing character in the rsync target specification.

The rsync job now runs fine if triggered from cron.

Thanks for the help!
 
  


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
[SOLVED] CIFS share on old WinNT host - smbclient works, mount -t cifs doesn't Electrode Linux - Networking 4 04-19-2012 09:11 AM
Bash script works in terminal but not in cron. rivacom Linux - General 21 06-16-2011 10:22 AM
[SOLVED] can't mount CIFS share, but smbclient and smb:// (KIO) works hasi Linux - Networking 15 10-15-2010 05:27 PM
Keep getting errors when running cron job that works in normal terminal. Techno Guy Linux - Newbie 6 05-31-2009 06:48 PM
works on command not on cron rickict Linux - General 1 11-17-2005 02:52 PM


All times are GMT -5. The time now is 08:23 PM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration