Posted on 09-20-2019 08:37 AM
I'm looking for a way to schedule the execution of a script at a specific time. I have deployed computers in our environment that have the same Deploy Studio image on it (this was Pre-Jamf). On the image, there is a scheduled restart that happens daily at 11pm- configured under Energy Saver system preferences pane. On some occasions, any open Applications sometimes will interrupt the restart. I have the script that closes all applications but need it to now run shortly before the 11pm restart. I know I can use Automator and iCal but would like to avoid that if at all possible so that I'm relying on Jamf.
Solved! Go to Solution.
Posted on 09-20-2019 08:54 AM
I agree with the launchdameon route. Another way is to time your script in the policy (under General tab), but your results may vary as the computers check-in.
Posted on 09-20-2019 08:49 AM
Personally I'd use a launchdaemon to do this. Here is an example
<?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>com.yourscript.org</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/sh</string>
<string>/Users/user/path/to/SCRIPT.sh</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>10</integer>
<key>Minute</key>
<integer>05</integer>
</dict>
</dict>
</plist>
Posted on 09-20-2019 08:54 AM
I agree with the launchdameon route. Another way is to time your script in the policy (under General tab), but your results may vary as the computers check-in.
Posted on 09-20-2019 08:55 AM
If you need it to run at a specific time, and not just a general timeframe, then a launchd job is really the best way to go. However, I'm not sure if a LaunchDaemon would be better than a LaunchAgent. As "agents" run as the currently logged in user, it might be possible to run your script in the user context. That will depend on whether anything in the script requires root privileges or not. If it doesn't need to invoke sudo or root commands, then an agent might give you better results.
You can test it out both ways to see.
Posted on 09-30-2019 06:20 AM
Thanks to all for your input. Because the span of time was somewhat vast, I ended up using @mvu 's suggestion through Jamf.