-   Linux - Software (
-   -   Rsync command to/from CIFS share does not work in cron, works in terminal? (

rylan76 02-12-2014 05:04 AM

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


/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


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


mount -t cifs // /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:

30 00 * * * sh -f /root/ > errors.txt 2>&1
where is


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

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


sh -f /root/
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/ rsync cannot see the /mnt/remote_software CIFS share, and the rsync fails.

Errors.txt then contains


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


//                  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?


pingu 02-12-2014 06:37 AM

I think the problem is the wildcard '*', it is read literally.
To test that, remove the '*' and add a directory instead.

rylan76 02-12-2014 09:53 AM


Thanks of the reply!

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

Thanks again

rylan76 02-17-2014 03:34 AM

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!

All times are GMT -5. The time now is 02:10 AM.