Table of Contents
- macOS: crontab, launchd, and launchctl
- Running a simple command every minute with Mac launchd
- 1) Move to the $HOME/Library/LaunchAgents directory
- 2) Create a Mac plist file to describe your job
- 3) Tell MacOS about your Mac plist launchd file
- 4) How Mac launchd works with system reboots
- An important note about root and sudo access
- MacOS launchd, launchctl, and plist resources
- MacOS startup jobs: cron and crontab, launchd and launchctl
MacOS crontab FAQ: How do I run a Unix job (or shell script) through the MacOS crontab facility? I keep trying to edit my Mac crontab file, but my Mac won't save my crontab changes, or run my program.Back to top
macOS: crontab, launchd, and launchctl
Way back when (~2012-2014), I found that the Mac
crontab command was deprecated on MacOS, and the Apple documentation encouraged you to use their launchd facility. Here’s a blurb from Apple's
crontab man page:
“Darwin note: Although cron(8) and crontab(5) are officially supported under Darwin, their functionality has been absorbed into launchd(8), which provides a more flexible way of automatically executing commands. See launchctl(1) for more information.”
Hmm, it looks like there might be more than one reason for Apple retiring their famous Mac/PC commercials -- turns out they've quietly gotten into the malware/antivirus business.
MacWorld reports that Apple has quietly snuck an anti-malware (antivirus) update into the latest round of Mac OS X Snow Leopard updates. An antivirus program was included in Snow Leopard, and last week's Snow Leopard update included an update to the Mac OS X antivirus definition file (a simple Mac OS X plist file).
Mac OS X launchd plist FAQ: Can you share some Mac OS X launchd/launchctl plist file format examples?
I started to write a long tutorial on the Mac OS X launchd plist format, but I think an easier way (for me) is to point you to a couple of references that explain the launchd plist format fairly well.
Mac OS X launchd plist FAQ: Can you share some examples of how to use the Mac OS X launchd plist StartInterval and StartCalendarInterval keys?
Here's a quick look at the Mac OS X launchd StartInterval and StartCalendarInterval keys. These two keys can be used to represent time values in a Mac launchd plist file, and many people have questions about them.
Mac OS X launchd plist StartInterval examples
The general syntax for the Mac OS X launchd plist StartInterval key is shown here:
Mac OS X launchd FAQ: Can you share some Mac launchd examples (also written as launchd plist examples, or launchctl examples)?
In an earlier tutorial (Mac OS X startup jobs with crontab, launchctl, and launchd) I demonstrated how to use the Mac OS X launchd facility instead of cron to run what would normally be a cron (crontab) job. As I started working with launchd and launchctl, I realized it would probably be helpful to see several different launchd examples, specifically launchd plist file examples.