To schedule script in OSX to run every now and then you can use launchd. Add a scheduled job by saving a .plist in folder **/Users//Library/LaunchAgents**. This example will run a php script every 10 seconds.
1. Example .plist
This example is saved as se.christianengvall.dostuff.plist in the folder mentioned above.
Set the label value to the same name as the file. In ProgramArguments we set the path to php and the path to the script we want to run. The StartInterval sets how often to run the script, set in seconds.
2. The php script
Nothing much going on here, just add a message to the system log.
3. Schedule script in OSX
Now to schedule the script run this in a terminal:
Now start the Console utility and watch your script print: “printing value to log” every ten seconds.
4. Stopping the script
I hope you find this post valuable. If you click the ad below I get paid by someone else and can continue to publish posts for free. I would appreciate it very much.