I'm trying to suspend or "sleep" a specific line in a bash script running in OSX. The script runs at startup before login. I'm not seeing the results I'm expecting. In other words no matter what time I specify after "sleep" the script still moves right along with no delay what so ever. However when I run the script after login, the "sleep" command seems to work just fine.
Is it possible that the command file "sleep" isn't in the path before login or before my script runs? Would it help if I placed the path to sleep before the command? If so where does "sleep" live?
Is there another approach or alternative command I could try?
Thanks
#!/bin/bash
#Create the bin directory
sudo mkdir /usr/local/bin
sleep 10
#Copy the files to the Hard Drive
sudo cp /Volumes/NO\ NAME/adbind.bash /usr/local/bin/adbind.bash
sudo cp /Volumes/NO\ NAME/com.sjusd.adbind.plist /Library/LaunchDaemons/com.sjusd.adbind.plist
#Fix permissions
sudo chown root:wheel /usr/local/bin
sudo chmod 755 /usr/local/bin
sudo chown root:wheel /Library/LaunchDaemons/com.sjusd.adbind.plist
sudo chmod 755 /Library/LaunchDaemons/com.sjusd.adbind.plist
exit 0
Dang tough crowd I got a minus 1 LOL
This might be a little late, but it seems that sleep on OS X doesn't work with quantifiers (m,h, ...). Official Apple documentation
So "sleep 5m" is the same as "sleep 5". If you want 5 minutes, you have to use "sleep 300"
If you run which sleep
, you can get the path to 'sleep' on your system. I get /bin/sleep
.
At this point, you have a couple of options:
you can specify the path to sleep
when you call it
#!/bin/bash
# script before sleep ...
/bin/sleep
# ... after sleep
or you can add the path to your $PATH
variable within your script before you call it.
#!/bin/bash
PATH="$PATH:/bin"
# script before sleep ...
sleep
# ... after sleep
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With