With the release of Mac OS 10.4, launchd was chosen to supersede cron in Mac OS.
Has anyone experience of writing a daemon to run get_iplayer regularly?
Or using launchd to run cron regularly?
If not I shall dive in and try and understand it, but I thought I would ask first.
[Yes I have tried to run cron as superuser or as root but it doesn't work and it's a bit of security risk]
[[Plus I have to get grips with eventually for other automated scripts I used to use]]
I use launchd to have get_iplayer update its cache regularly. As far as I know it's working properly! Create the following text file:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.{YOUR_DOMAIN}.get_iplayer.cache_refresh</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/get_iplayer</string>
<string>--refresh</string>
<string>--type=tv,radio</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>518400</integer>
</dict>
</plist>
Give it the same name as the "Label" property in the plist:
Code:
org.{YOUR_DOMAIN}.get_iplayer.cache_refresh.plist
and place it in:
Code:
~/Library/LaunchAgents/
It will then load at login, but you can load it manually using the terminal:
Code:
launchctl load ~/Library/LaunchAgents/org.{YOUR_DOMAIN}.get_iplayer.cache_refresh.plist
If you want to create your own/play around/understand the values better, there is a
launchd plist generator website. But to really help understand the files, I highly recommend
LaunchControl, which is an advanced utility for working with launchd and its plist files. It has a free trial, and even once the trial expires, it's a great way to explore the various properties and their options (or if you find yourself using it, you can buy it obviously!).