I run rsync in the cron every 4 hours. This works well for backups, but it generates six messages a day to root for each successful backup. I know I can put the output to /dev/null not to get any e-mail messages to root at all, but what I really want is exception reporting. In other words, only send an e-mail message to root if the rsync fails or has any problem completing normally. Is there a way to do this without having it also send e-mail to root every 4 hours? Thanks!


If I recall, rsync will set a non-zero exit code if there are errors.

Just write a simple shell script to run your sync and collect stdout and stderr. At the end of the run, check the exit code. If it's zero, it ran successfully and you can exit. If non-zero, send your error email.

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.