We have a cron job running to rsync files from one server to a different host. The cron runs daily at midnight. The file copy is critical for us so we want to monitor the backup runs. We want to monitor two things...

1. rsync run
2. Also would like to check whether it failed in the middle of the run . 

Please suggest .

  • 1
    Look at the output it produces? – roaima Oct 5 '15 at 8:53

What do you mean by "monitoring rsync run"? Do you mean the duration, the end time, memory usage or something else?

Anyway, you or your IT may already have some monitoring system in place, so answering this depends on if this is the case or not.

Assuming there's no monitoring system, then just send an email to yourself if the exit status is != 0. There are various ways to do this, which I consider beyond the scope of this answer.

  • It copies around MBs of data . Want to check whether it is successful in copying all the data or failed in the middle while copying the data – Zama Ques Oct 5 '15 at 13:28
  • 1
    OK, so checking the exit status is the way to go. – Jan Oct 5 '15 at 15:37

I usually write my rsync backup scripts (and several other kinds of cron jobs) so that they have code like the folowing at the start of the script, immediately after the #! line.

BNAME=$(basename "$0" .sh)
mkdir -p /var/log/cronjobs
savelog $LOGFILE
exec &> $LOGFILE

Combined with rsync --verbose --stats ---progress it works well to log everything that the rsync job does.

You can monitor progress with tail -f or tail -F but if you want to view the log file with less you'll have to use less -r or less -R

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.