Set up timed or recurring scripts
It’s fairly straightforward to leverage launchd to run a script either at specified intervals or at specific times of the day. I find that most people only want to do fairly simple things, so I’ve kept this simple.
The way launchd works is that you create a plist, then run a command to either load or unload the plist. Here is an example plist that will run the script called “rsync-backup-work” every 3 hours. The first 3 lines are just boilerplate for a plist.
<?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>org.cricket.rsync-backup-work</string
<key>ProgramArguments</key>
<array>
<string>/Users/admin/bin/rsync-backup-work</string
</array>
<key>StartInterval</key>
<integer>10800</integer>
</dict>
</plist>
This has only three keys:
Label → Unique identifier (this can just…
Keep reading with a 7-day free trial
Subscribe to Tech Reflect to keep reading this post and get 7 days of free access to the full post archives.