Schedule Timed Jobs on macOS with `launchd`

InstructorCameron Nokes

Share this video with your friends

Send Tweet

launchd is a robust scheduled job automation tool on macOS that allows you to schedule a task to be run at recurring times. It's macOS's take on Linux's cron. In this lesson, we’ll schedule a simple bash script that empties the Trash to run every Monday morning at 10am.

First, we’ll create a plist file (a plist file is just XML) with our job configuration. In here, we’ll specify our bash script as the program to run. Then we move plist file to the ~/Library/LaunchAgents folder. Then we’ll use launchctl to load our configuration file, which will make the job active. We'll manually activate our job to ensure it's working with launchctl kickstart.