My script is:
#!/bin/bash
# Path to a lock folder
LOCK_PATH="/Volumes/PROOFS_WATCH/copy.lock"
trap 'rmdir "$LOCK_PATH"; exit' 1 6 15
if mkdir "$LOCK_PATH"; then
echo "Lock file did not exist and was created, Copying..."
# Perform commands
cp /Volumes/PROOFS_WATCH/*.mov /Volumes/PROOFS_WATCH/AME_Processing/
cp /Volumes/PROOFS_WATCH/*.mov /Volumes/PROOFS_TV
rm /Volumes/PROOFS_WATCH/*.mov
# Remove the lock
rm -f "$LOCK_PATH"
fi
My Output is:
Lock file did not exist and was created, Copying...
cp: /Volumes/PROOFS_WATCH/*.mov: No such file or directory
cp: /Volumes/PROOFS_WATCH/*.mov: No such file or directory
rm: /Volumes/PROOFS_WATCH/*.mov: No such file or directory
rm: /Volumes/PROOFS_WATCH/copy.lock: is a directory
logout
[Process completed]
rm -f
does not remove the lock folder for some reason...
I would like this script to run automatically via Cron every 60 seconds. If a large file is being written though I don't want it to run until the file write is complete.
Im realizing more of what can be done with bash and I want to automate more processes as well.