Help with LaunchD running script

ImAMacGuy
Valued Contributor II

I've been using a process that was developed by macmule. It's mostly still working across the various OS's. However, I'm trying to get it to sync to an external drive rather than an internal drive. When I point the script to the external drive, the script seems to be running prior to the drive being registered, so the script is creating a folder in /Volumes and starts replicating. The drive then finishes mounting, but has a 1 appended to the end which makes it the wrong path. I tried adding a sleep timer but it didn't seem to work (shown).

I've tried

'"/Volumes/Peg...."'

and with various versions of ", `, and even manually putting the path in with \ commands (.../Pegasus\ -\ SA)

 

Here's how it's setup now.

sleep 15
emailAlert=$(/usr/bin/rsync -avrpogz --delete --log-file=/private/var/log/rsync.log -e ssh ':"/Volumes/Promise RAID-File Share/CasperShare"' "/Volumes/Pegasus - SA")

 

1 ACCEPTED SOLUTION

mm2270
Legendary Contributor III

You could adding an until block to check for the existence of the volume before proceeding with the rsync.

Like

until [ -e "/Volumes/Pegasus - SA" ]; do
     sleep 15
done
emailAlert=$(/usr/bin/rsync -avrpogz --delete --log-file=/private/var/log/rsync.log -e ssh ':"/Volumes/Promise RAID-File Share/CasperShare"' "/Volumes/Pegasus - SA")

Not tested of course, so the above may or may not work, but the script should keep looping every 15 seconds until it successfully sees the volume mounted, then exit the loop and go ahead with the sync.

View solution in original post

2 REPLIES 2

mm2270
Legendary Contributor III

You could adding an until block to check for the existence of the volume before proceeding with the rsync.

Like

until [ -e "/Volumes/Pegasus - SA" ]; do
     sleep 15
done
emailAlert=$(/usr/bin/rsync -avrpogz --delete --log-file=/private/var/log/rsync.log -e ssh ':"/Volumes/Promise RAID-File Share/CasperShare"' "/Volumes/Pegasus - SA")

Not tested of course, so the above may or may not work, but the script should keep looping every 15 seconds until it successfully sees the volume mounted, then exit the loop and go ahead with the sync.

ImAMacGuy
Valued Contributor II

This worked. thank you so much!