Setting Up a Recurring Task on MacOS

Traditionally, on *nix systems, cron (or one of its derivatives) is used. It’s possible to use cron on the Mac, but it’s deprecated. launchd is the preferred method. The set up is a little more complex because it’s a bit of XML code, but it’s very straightforward. See the launchd.plist man page or the launchd info website for more information.

I set up dynamic DNS for a remote server in my domain, and wanted to have it update its DNS record once a day at 7am. You create a file in /Users/<yourloginname>/Library/LaunchAgents with the PLIST naming scheme: com.technomancer.updatedns.plist and put in code of the form:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">







After you create this, to load it into launchd, run the command:

launchctl load com.technomancer.updatedns.plist 

To stop it, just use unload instead of load.

NOTE! You cannot run the launchctl commands correctly unless you are logged in to the GUI. They will fail otherwise.

Leave a Comment