Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a CentOS 5.5 x64 server that mirrors a NetGear ReadyNAS Everynight at midnight using rsync. I need a way to be alerted if the backups fail.

I have this in my users cron. It does run and works fine.

0 0 * * * /usr/bin/grsync-batch -f /home/user/jobname.grsync 2>&1 > /home/user/logfile

I do not run rsync as a daemon, so I do not think I can specify a syslog. I have a managed systems server that can watch for SNMP alerts and syslogs events if I know what error to tell it to look for. I monitor my mail server by checking if postfix and amavis are running and accepting connections and if not I run 'logger -p 'whatever error here' and then the Monitor server checks the log every hour and if that is in there, it alerts everyone. It would be OK if I could do something like that in a script.

How does everyone else alert themselves when rsync encounters an error?


share|improve this question
up vote 1 down vote accepted

Create a shell script to be called by cron. Within that shell script, place the grsync-batch command (along with options)....

grsync-batch ... > logfile 2>&1
if [ "$?" -ne "0" ]; then
     mail -s "rsync error" < logfile

$? is the exit code of the last command. 0 usually means success and anything else means an error occured.

rsync man page (exit values at the bottom)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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