?
Solved

How do I return an exit code with Rsync?

Posted on 2005-04-11
1
Medium Priority
?
415 Views
Last Modified: 2013-12-16
Hi all,

Take any rsync script... I'm interested to know how to use the exit code rsync provides to determine success or failure.

For example,

# /bin/bash
rsync -a /foo /bar

How do I do an "if then" to catch the exit code then perform an action (i.e. if exit code > 0, echo "there is a problem" into a logfile)

Thanks,
DS
0
Comment
Question by:dsstao
1 Comment
 
LVL 51

Accepted Solution

by:
ahoffmann earned 500 total points
ID: 13754511
rsync ....
if [ $? -ne 0 ]; then
  echo error >> logfile
fi
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month16 days, 11 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question