For some reason, I am unable to get my shell script to run when the computer boots. My script fine by itself, but for some reason my Launch Daemon is not starting the job. Please help.

My launch daemon is saved in /Library/LaunchDaemons/local.pingtest.plist

My Launch Daemon Plist: enter image description here

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">

my shell script: enter image description here

/usr/bin/nohup /sbin/ping -i 5 ipaddress | /usr/bin/xargs -L 1 -I '{}' date '+%Y-%m-%d %H:%M:%S: {}' >> /pingtest/Ryan-lou.txt &

/usr/bin/nohup /sbin/ping -i 5 www.google.com | /usr/bin/xargs -L 1 -I '{}' date '+%Y-%m-%d %H:%M:%S: {}' >> /pingtest/Ryan-int.txt &

/usr/bin/nohup /sbin/ping -i 5 ipaddress | /usr/bin/xargs -L 1 -I '{}' date '+%Y-%m-%d %H:%M:%S: {}' >> /pingtest/Ryan-fcc.txt &

First I'd check the path of pingtest.sh relative to how it's defined in local.pingtest.plist.

I've not played around with the launch daemon on Macs yet but there may be some special need for it to be in /System/Library/LaunchDaemons instead. Not sure why it'd end up ignoring the other location by the time you're logged in and looking at it but I've seen specifications ignored before on systems so worth a try.

Next I'd check for things like conflicting Label identifiers and that my other keys mean what I think they mean.

Doesn't look like your script is dependent on non-launchd daemons, but those are things to keep in mind.

| improve this answer | |

"Parsing" the script launchctl throws an error "nohup: can't detach from console: Inappropriate ioctl for device" and expects another command after the last &.

Add a proper shebang and remove the /usr/bin/nohup part as well as the last & in your shell script and it works:


/sbin/ping -i 5 www.google.com | /usr/bin/xargs -L 1 -I '{}' date '+%Y-%m-%d %H:%M:%S: {}' >> /pingtest/Ryan-lou.txt &
/sbin/ping -i 5 ip1 | /usr/bin/xargs -L 1 -I '{}' date '+%Y-%m-%d %H:%M:%S: {}' >> /pingtest/Ryan-int.txt &
/sbin/ping -i 5 ip2 | /usr/bin/xargs -L 1 -I '{}' date '+%Y-%m-%d %H:%M:%S: {}' >> /pingtest/Ryan-fcc.txt
| improve this answer | |
  • I made the changes above and restarted my Mac. It created the 3 .txt files, but they are blank. ps aux | grep ping shows that the pings are not running. – rdweise76 Dec 9 '16 at 19:40
  • @rdweise76 Hmm, I tested it in a VM and it worked properly. Maybe the launch daemon is not running or wrong permissions set... – klanomath Dec 9 '16 at 19:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .