Launchd is the official way to schedule a task or run a service on OSX. The provided documentations goal is to turn you into a launchd expert at the cost of your afternoon. These are the 5 minute highlights to get a task running.
You tell launchd to run a task by putting a reverse domain named plist file(
~/Library/LaunchAgents, this is probably what you are looking for but if you want it to be global then put it in
This file needs to have 600 permissions
chmod 600 com.example.name.plist and be owned by
chown root com.example.name.plist.
Launchd tasks are run from
/ so all paths should be relative from that point.
The following commands are self explanatory. If you change your plist you need to unload/load it again for the changes to take effect.
launchctl list | grep com.task.name
sudo launchctl unload com.davidhampgonsalves.markov-tumblr.plist
sudo launchctl load -w com.davidhampgonsalves.markov-tumblr.plist
You can force a run of your task with
sudo launchctl start com.markov-tumblr,
The best way I have found is to keep a tail of the syslog running with:
tail -F /var/log/system.log. decipher any error numbers with
launchd error <error number>.