2

Below is an example of what I'm trying to do:

    <?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">
    <dict>
        <key>Label</key>
        <string>fooLabel</string>
        <key>Something</key>
        <string>/bin/bash foo -arg 1 -arg 2 &</string>
</dict> 
</plist>

The plist was added to /Library/LaunchDaemons so it should run at boot for all users, right? The appropriate file permissions were set.

The script needs to run as a background process and also requires network connectivity. How can I make sure the plist doesnt launch until internet access is established?

3

You want to include this check for network state:

<dict>
  <key>NetworkState</key>
  <true/>
</dict>

Also - you probably want to pass in your program args correctly:

<key>ProgramArguments</key>
<array>
    <string>/usr/local/bin/binaryname</string>
    <string>arg1</string>
    <string>arg2</string>
</array>
  • 1
    thanks for your help. im still having some trouble. could you show an example of using args for the following command? tail -n100 /var/log/foo.log | curl -s --data - http://website.com/upload/ 2>&1 >/tmp/bar – lily May 19 '18 at 2:48
  • 2
    Much easier to wrap up what you want to do into a script and call that from launchd. – Alex May 19 '18 at 3:20

You must log in to answer this question.

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