I want to create a delay 60 sec with in plist to start my Daemon and Agent.

I tried using the StartInterval and ThrottleInterval. It starts up but to soon which conflicts with another application I am running that is why I wanted to run a delay on this.


This is the example of my runnign plist:


<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">

<dict>

<key>Label</key>

<string>com.connector.agent</string>

<key>RunAtLoad</key>

<true/>

<key>ThrottleInterval</key>

<integer>60</integer>

<key>KeepAlive</key>

<key>SuccessfulExit</key>

<false />

</dict>

<key>ProgramArguments</key>

<array>

<string>/Applications/Connector.app/Contents/MacOS/Connector</string>

<string>-agent</string>

</array>

</dict>

</plist>

Answered by DTS Engineer in 280958022

Adding arbitrary delays like this is almost always a bad idea. What happens if the other process takes a long time to start up because, say, it makes a network request and the network is slow today? It’s generally better to use some sort of dependency check rather than just delay and hope.

Regardless, to answer your specific question there’s no way to tell

launchd
to delay the start of your agent. However, there’s nothing stopping you from adding your own delay. You’re already passing the
-agent
argument to your agent, so it knows it’s running in agent mode, and thus it can just add a delay to the start of
main
.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
Accepted Answer

Adding arbitrary delays like this is almost always a bad idea. What happens if the other process takes a long time to start up because, say, it makes a network request and the network is slow today? It’s generally better to use some sort of dependency check rather than just delay and hope.

Regardless, to answer your specific question there’s no way to tell

launchd
to delay the start of your agent. However, there’s nothing stopping you from adding your own delay. You’re already passing the
-agent
argument to your agent, so it knows it’s running in agent mode, and thus it can just add a delay to the start of
main
.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thanks for the answer.

Is it possible to run a 60 second interval between the end of execution and start of next execution?

No.

Or to skip the run if the previous process has not exited?

That happens automatically. If a job is running (in a specific domain) launchd will not run it again.

In most cases launchd jobs should not terminate themselves. Rather, an ideal launchd job should:

  • Use no resources (other than memory) if it’s idle.

  • Notify the system when it becomes active and inactive.

  • Allow the system to stop the job if it needs memory.

See the launchd.plist man page man page discussion of EnablePressuredExit for more.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I want to create a delay 60 sec with in plist to start my Daemon and Agent.
 
 
Q