launchd plist generator
A launchd job is a plist file in ~/Library/LaunchAgents with a Label, ProgramArguments and a schedule key (StartCalendarInterval or StartInterval). Fill in the form to get the finished file and the launchctl commands that load it.
Free, and it runs in your browser: nothing you type here is sent anywhere.
Every day at 02:30 local time.
com.example.nightly-backup.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>com.example.nightly-backup</string> <key>ProgramArguments</key> <array> <string>/usr/local/bin/backup.sh</string> <string>--target</string> <string>/Volumes/Backup Drive</string> </array> <key>StartCalendarInterval</key> <dict> <key>Hour</key> <integer>2</integer> <key>Minute</key> <integer>30</integer> </dict> <key>StandardOutPath</key> <string>/tmp/nightly-backup.log</string> <key>StandardErrorPath</key> <string>/tmp/nightly-backup.log</string> </dict> </plist>
Load it
mkdir -p ~/Library/LaunchAgents cp com.example.nightly-backup.plist ~/Library/LaunchAgents/com.example.nightly-backup.plist plutil -lint ~/Library/LaunchAgents/com.example.nightly-backup.plist launchctl bootout gui/$(id -u)/com.example.nightly-backup 2>/dev/null launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.example.nightly-backup.plist
Check it, run it now, and remove it:
launchctl print gui/$(id -u)/com.example.nightly-backup launchctl kickstart -k gui/$(id -u)/com.example.nightly-backup launchctl bootout gui/$(id -u)/com.example.nightly-backup rm ~/Library/LaunchAgents/com.example.nightly-backup.plist
How to schedule a script on a Mac with launchd
- Enter a unique label and the full path of the command or script you want to run.
- Choose when it runs: a daily time, certain weekdays, a day of the month, or every N minutes.
- Copy or download the plist, save it as <label>.plist, then run the load commands in Terminal.
- Check it with launchctl print, trigger a test run with kickstart, and read the log file you set.
Plist keys the generator writes
| Key | What it does |
|---|---|
| Label | Unique job name, also used in launchctl commands. |
| ProgramArguments | The command split into arguments. No shell unless you ask for one. |
| StartCalendarInterval | Clock times (Hour, Minute, Weekday, Day). Local time, not UTC. |
| StartInterval | Seconds between runs while the Mac is awake. |
| RunAtLoad | Run once as soon as the job is loaded. |
| StandardOutPath / StandardErrorPath | Where output and errors are written. |
| WorkingDirectory | Folder the job starts in. |
Source: Apple, launchd.plist(5) manual page.
Questions
Where do I put the plist file?
Put it in ~/Library/LaunchAgents to run as you when you are logged in, or /Library/LaunchDaemons (owned by root) to run at the system level. The file name should match the Label, for example com.example.backup.plist.
What is the difference between StartInterval and StartCalendarInterval?
StartInterval runs the job every N seconds while the Mac is awake. StartCalendarInterval runs it at clock times such as 02:30 daily or Monday at 09:00. If the Mac is asleep at a calendar time, launchd runs the job once when it wakes. A Mac that is shut down skips the run.
Why does my job not run when I use launchctl load?
launchctl load is the legacy form. Current macOS expects launchctl bootstrap gui/$(id -u) with the plist path. If the job still fails, run plutil -lint on the file and read the log paths set in StandardOutPath and StandardErrorPath.
Does launchd use my shell, PATH and environment?
No. launchd starts the program with a minimal environment and a PATH of /usr/bin:/bin:/usr/sbin:/sbin, so Homebrew tools need their full path. It also does not expand ~ in the log or working directory paths, so write /Users/you/... instead. For pipes, redirects or variables the generator wraps the command in /bin/sh -c.
Can launchd run a job on the last day of the month?
Not directly. StartCalendarInterval takes a fixed Day, so day 31 is skipped in shorter months. Run the job daily and have the script exit unless tomorrow is the 1st, for example [ "$(date -v+1d +%d)" = 01 ] || exit 0. RunLater accepts L in the day field (0 9 L * *) for the last day of every month.
Need it to run when your Mac is off?
A launchd job only runs while the Mac is on and awake. RunLater calls any URL on an exact time or a cron schedule from the cloud, with retries, a log of every run and an alert email when one fails. Point it at an endpoint or webhook that starts your job.
Starter is $15/month for 250 scheduled requests and 25,000 runs. Cancel before day 14 and you pay nothing.