I have the following bash script which kicks off every hour via cron job. My remote server drops the connection every now and again that is why I run it every hour. I have a line that checks for the process, if the process exists it does start a new one, if the process does not exist it runs the rsync job again and starts off where it left off.
The problem I am having is that even when the remote server drops the connection the script just hangs and still shows as a running process.
# Check for rsync running under my username
if ps ax | grep -v grep | grep user | grep $SERVICE > /dev/null
echo "The process exists..." >> $RUNLOG
# Run rsync command
echo "Starting rsync..." >> $RUNLOG
rsync -aP --update --bwlimit=300 -e 'ssh -p 2222' /vault/ firstname.lastname@example.org:/home/user/vault >> $RUNLOG