Notice: register_sidebar was called incorrectly. No id was set in the arguments array for the "Sidebar 1" sidebar. Defaulting to "sidebar-1". Manually set the id to "sidebar-1" to silence this notice and keep existing sidebar content. Please see Debugging in WordPress for more information. (This message was added in version 4.2.0.) in /usr/share/wordpress/wp-includes/functions.php on line 4139 Tech Notes » Blog Archive » Scheduling Cyclic Jobs in MacOSX

Scheduling Cyclic Jobs in MacOSX

How to Add comments

Many of us UNIX old-timers are quite accustomed to cronjobs, but MacOSX has a centralized “LaunchDaemon” called launchd — to leverage it to run cronjobs gives an OS-specific, perhaps OS-preferred, method of doing so.

The TL;DR:

<?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.example.rsync.SyncTheRepos</string>

<key>Program</key><string>/usr/bin/rsync</string>

<key>ProgramArguments</key>

<array>

<string>-avr</string>

<string>–delete-after</string>

<string>rsync.example.com::repos</string>

<string>~/Documents/Repos</string>

</array>

<key>EnableGlobbing</key><true/>

<key>StartCalendarInterval</key>

<dict>

<key>Hour</key><integer>3</integer>

<key>Minute</key><integer>14</integer>

</dict>

<key>ProcessType</key><string>Background</string>

</dict>

</plist>

In general, there is a lot of flexibility in setting up a launchd plist — the config info on https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man5/launchd.plist.5.html plus the various examples on the internet should help, but I generally take this example and re-use it.

Once this plist is saved as a local text file in ~/Library/LaunchAgents/ (for example, I’ll save mine as ~/Library/LaunchAgents/rsync-repos.plist), I activate it using:

launchd load -w ~/Library/LaunchAgents/rsync-repos.plist

If I want to disable the job, I use:

launchd unload -w ~/Library/LaunchAgents/rsync-repos.plist

The files are not modified in either case.

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in