Quickly set up a daemon/agent on macOS to run scheduled tasks. Launchd is the recommended solution for MacOS, and is analogous to cron jobs for Linux and Task Scheduler for Windows.
Setting up launchd can be tedious. This repository provides a turnkey demo to get an initial launchd task working on your machine. The repo demonstrates the following automated tasks:
- Create a new folder at a 10 second interval:
launchd.makeFolder.plist - Launch an application at a 20 second interval:
launchd.launchApplication.plist - Execute a Python script at a 10 second interval:
launchd.runScript.plist
You can build off of this simple demo for use cases such as:
- Send email messages or publish social media at a scheduled time
- Schedule sounds effects, wallpaper changes, or application launches
- Configure recurring backups, maintenance tasks, and system maintenance
- Clone the repository
- Execute the p-list file:
launchctl bootstrap gui/<user_id> <filepath to p-list file> - Your daemon is now running!
- End the program:
launchctl bootout gui/<user_id> <filepath to p-list file>
- You can check your user_id using
id -u. - You can check if the daemon is running using
launchctl list <name of daemon/agent as specific by label key in p-list file>.