0

I have the following crontab entry to automate copying of my files to separate W/S in the network. However, it does not copy the files but produce the log file. here is the file contents

#! /bin/bash
echo "Rsync - MA Inbound Files"
rsync -rvu /media/hdd2/MA-Inbound /media/miracle/
echo "Completed MA Inbound Files Sync, Starting Tally.ERP 9 Data File Sync"

rsync -rvu /media/hdd2/Tally.ERP9 /media/miracle/
echo "Completd Tally.ERP9 Data File Sync, Starting 2011 Accounts Files Sync"

rsync -rvu /media/hdd2/"2011 Accounts" /media/miracle/
echo "Completd 2011 Accounts Files Sync, Starting 2012 Accounts Files Sync"

rsync -rvu /media/hdd2/"2012 Accounts" /media/miracle/
echo "Completd 2012 Accounts Files Sync, Starting 2012 Files Sync"

rsync -rvu /media/hdd2/"2012 Files" /media/miracle/
echo "Completd 2012 Files Sync, Starting 2013 Accounts Files Sync"

rsync -rvu /media/hdd2/"2013 Accounts" /media/miracle/
echo "Completd 2013 Accounts, Starting Admin Files Sync"

rsync -rvu /media/hdd2/"Admin" /media/miracle/
echo "Completd Admin Files Sync, Starting MA_Staff Data File Sync"

rsync -rvu /media/hdd2/MA_Staff /media/miracle/
echo "Completd MA_Staff Data File Sync, Starting MA-Outbound Data File Sync"

rsync -rvu /media/hdd2/MA_Outbound /media/miracle/
echo "Completd MA-Outbound Data File Sync, Starting Staff Pic Data File Sync"

rsync -rvu /media/hdd2/"Staff Pic" /media/miracle/
echo "Completd Staff Pic Data File Sync, End OF Syn"

here is the command which I have put in the crontab file

30 22 * * * /Desktop/marsync.sh >AutoRsyncLogfile.txt

When I copy these commands individually, it works flawlessly

Hope some one can help me out wit this.....

Thank you

Jeremy Kerr
  • 27,199
Neil
  • 237
  • 4
  • 10
  • 21

2 Answers2

3

You don't state what the log file contains; I assume it's empty.

If that's the case, it looks like your problem is due to the path used in the crontab file:

30 22 * * * /Desktop/marsync.sh >AutoRsyncLogfile.txt

The /Desktop part is probably incorrect; the Desktop directory is usually in your home directory (ie, /home/<username>), and can be referenced by the $HOME environment variable.. If you change this to something like:

30 22 * * * $HOME/Desktop/marsync.sh >AutoRsyncLogfile.txt

- then this should work. You'll also need to ensure that the marsync.sh file is executable:

chmod a+x $HOME/Desktop/marsync.sh

Also, you might want to capture standard error (in addition to standard output) to your log file. Use &> to do this:

30 22 * * * $HOME/Desktop/marsync.sh &>AutoRsyncLogfile.txt
Jeremy Kerr
  • 27,199
  • 30 22 * * * $HOME/Desktop/marsync.sh &>AutoRsyncLogfile.txt did not work. I will try few other paths.... I think like u said it could be the path.... – Neil Aug 31 '14 at 06:10
-1

You have to call all commands including path : /usr/bin/rsync , or specify path in the script: look here

laugeo
  • 2,827
  • 1
    You'll generally have a standard, minimal PATH - (/usr/bin:/bin), which is very likely to contain rsync in a default Ubuntu install. – Jeremy Kerr Aug 25 '14 at 12:12