Skip to content

Instantly share code, notes, and snippets.

@todgru todgru/
Last active Oct 25, 2019

What would you like to do?
Launchd and plist, replace cron in Mac OS X

#launchd Usage

I have a bash script called that takes one command line argument, bar. I want it to run every 60 seconds and load at startup.

  • an XML plist is Apple Property List
  • Name of launchd plist file should be a reverse fqdn, like (this may not be required, but convention)
  • lives in $HOME/Library/LaunchAgents and is ran as that user.
  • can also live /Library/LaunchDaemons or /Library/LaunchAgents, have requirements, ran as root
  • Load plist with launchctl load
  • Unload plist with lauchctl unload
  • Check /var/log/system.log if you are having issues with plist


"If the system is turned off or asleep, cron jobs do not execute; they will not run until the next designated time occurs. If you schedule a launchd job by setting the StartCalendarInterval key and the computer is asleep when the job should have run, your job will run when the computer wakes up. However, if the machine is off when the job should have run, the job does not execute until the next designated time occurs."

Example plist for

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







for reference:


This comment has been minimized.

Copy link

dhinostroza commented Oct 25, 2019

Following your example, I have the following lines inside my

REDCap Cron Job (runs every minute)

          • /usr/bin/php /Applications/MAMP/htdocs/redcap/cron.php > /dev/null
            (5 asterisks)

But I'm getting the following error message in foo.err:
/Users/ssd/bin/ line 2: Applications: command not found

I guess the old crontab format needs to be reformatted for launchd to understand it.
Can you give me some insight on this?
dhinostroza AT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.