How to use launchd on Mac

I tried to use crontab on Mac but it didn’t work so I learned how to use launchd. Here is how:
1. Create a plist file under your ~/Library/LaunchAgents folder and make sure it named something like "test1.plish".
2. sudo chmod 600 test1.plish
3. sudo chown root test1.plish
4. sudo launchctl load -w test1.plish

You can stop the demon by:
sudo launchctl unload test1.plish.

Another thing I learned afterwards is the environment of daemon is different from yours. So you need to use absolute path when calling commands that are not available in daemon’s path.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a comment