Created
March 23, 2021 14:52
-
-
Save annawoodard/49928dde66f748ea284b2394ec2d4a17 to your computer and use it in GitHub Desktop.
rsync radiology -> cri
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LOCK_NAME="chimec_sync" | |
LOCK_DIR='/tmp/'${LOCK_NAME}.lock | |
PID_FILE=${LOCK_DIR}'/'${LOCK_NAME}'.pid' | |
if mkdir ${LOCK_DIR} 2>/dev/null; then | |
# If the ${LOCK_DIR} doesn't exist, then start working & store the ${PID_FILE} | |
echo $$ > ${PID_FILE} | |
rsync --remove-source-files -avPz /mnt/hiro/ [email protected]:/gpfs/data/huo-lab/Image/ChiMEC/ >& /home/annawoodard/rsync.log | |
rm -rf ${LOCK_DIR} | |
exit | |
else | |
if [ -f ${PID_FILE} ] && kill -0 $(cat ${PID_FILE}) 2>/dev/null; then | |
# Confirm that the process file exists & a process | |
# with that PID is truly running. | |
echo "Running [PID "$(cat ${PID_FILE})"]" >&2 | |
exit | |
else | |
# If the process is not running, yet there is a PID file--like in the case | |
# of a crash or sudden reboot--then get rid of the ${LOCK_DIR} | |
rm -rf ${LOCK_DIR} | |
exit | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment