I have the following rsync script that I use for syncing MySQL files from one server to another. I run the script at 20 minutes past every second hour in cron. I want to make sure that the script completes in it's entirety before it is set to kick off again. For example, when the script starts at 1:20pm, it should finish before the 3:20pm interation of the script. If the 1:20pm script is still running, I would want the 3:20pm interation of the script to not run and maybe even send me an email. Below is the script I have as it currently runs. Any help, suggestions would be appreciated
# Variables
#
REMHOST="serverB"
ERRFILE="/tmp/rsync_mysql_error.log"
MAIL_LIST="System.Administrator@mydomain.com"
# Following options equate to: preserve links,recursive,preserve permissions,
# preserve times,quiet,and compress
OPTS="-lrptqz"
#NOTE: You must put a slash (/) at the end of your paths for the dirs to copy correctly!
/usr/local/bin/rsync $OPTS /apps/mysql/data/var/ $REMHOST:/apps/mysql/data/var/ > ${ERRFILE}
if [ -s ${ERRFILE} ]; then
mailx -s "/apps/mysql/mysql_rsync.ksh script encountered an error...Please investigate." ${MAIL_LIST} < ${ERRFILE}
fi
rm ${ERRFILE}