Since there is no "Year" parameter in the launchd
plist format, how is it possible to create an agent that will run only once and not once a year?
Launch Agents are often installed to perform updates to programs, launch user specified programs at login, or to conduct other developer tasks. Launch Agents can also be executed using the Launchctl command. Adversaries may install a new Launch Agent that executes at login by placing a .
Using a launch daemon is another privilege escalation method applicable to Apple-based operating systems, especially OS X. When OS X boots up, launchd is normally run to end system initialization.
There's no unique uninstall process for this—simply trash the . plist file and reboot your Mac. Or you can cut and paste it to your desktop to keep a copy to be on the safe side. Don't delete any items from the System LaunchAgents or System LaunchDaemons folders, as they're required for macOS to run smoothly.
The launchd process is used by macOS to manage daemons and agents, and you can use it to run your shell scripts. You don't interact with launchd directly; instead you use the launchctl command to load or unload launchd daemons and agents.
Since your reference "Year", I assume you are using StartCalendarInterval. If you don't want to run at an interval, use the RunAtLoad key, which will cause it to run once each time the system starts.
<key>RunAtLoad</key>
<true/>
Now if you truly only want the script to run once (ever), don't use launchctl at all, just run it once on the command line and be done with it.
Use the key LaunchOnlyOnce
for this:
<key>LaunchOnlyOnce</key>
<true/>
This will launch the agent only once if the system is not rebooted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With