I try to work with Launchctl
and have a question:
How can I set up an application to run in a few minutes using Launchctl
? (for example, open the program MyApp.app with arguments "hello" "world" Every 10 minutes)
I know that it can easily be done by creating Launch Agent
, I looking for a way to do it using Launchctl
directly to programmatically.
Best Answer
launchctl
is for loading, manipulating and unloading LaunchAgents and LaunchDaemons, it doesn't directly support delayed execution. What you can do instead issleep $((10 * 60)); launchctl submit -l my_choosen_name mkdir /tmp/mydir
launchctl submit -l my_name -- bash -c 'sleep 6$((10 * 60)) && mkdir /tmp/mydir'
sleep
in the script before it starts the applicationTo have it run every 10 minutes use