The easiest way to do this is use an App called LaunchControl. It saves having to do the details of a plist. It also can generates the correct StartInterval from a cron time specification. There is also Lingon. Both these are commercial and cost money. LaunchControl also describes what each possible key in the plist does.
In this case the keys that you need are
- Program - best to use the full path here and also in cron
- StandardOutPath - to say where the output should go - dealing with your > issue.
- StartCalendarInterval - to say when it runs
The plist generated by Launch Control is
<?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>test</string>
<key>Program</key>
<string>/bin/date</string>
<key>StandardErrorPath</key>
<string>/tmp/test.stderr</string>
<key>StandardOutPath</key>
<string>/tmp/cron_test.log</string>
<key>StartCalendarInterval</key>
<array>
<dict/>
</array>
</dict>
</plist>
>
, that seems to break the program parameters. My aim is to run a launchdaemon that checks a parmeter (for example the date) and outputs results to a log. Maybe I am better off withcrontab
and notlaunchd
? Hoping you can guide me and thanks again!