Launchctl code for triggering a farmbot script

I thought this might be useful for others as i was initially trying unsuccessfully to trigger it via crontab. And instead wound up using the verbose syntax of plist. The code cd’s into a dir and then triggers a python script at 1pm and 8pm. For those that are interested i’m using a sort of hacked version https://github.com/xebia/farmbot-py

put the plist file into your ~/Library/LaunchAgents/

<?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>your.file.name.here</string>
	<key>StandardOutPath</key>
        <string>/path/to/stdout</string>
        <key>StandardErrorPath</key>
        <string>/path/to/errout</string>
	<key>WorkingDirectory</key>
        <string>/path/to/code</string>
        <key>ProgramArguments</key>
	<array>
		<string>/path/to/python</string>
		<string>/path/to/file.py</string>
	</array>
	<key>StartCalendarInterval</key>
	<array>
		<dict>
			<key>Hour</key>
			<integer>13</integer>
		</dict>
		<dict>
			<key>Hour</key>
			<integer>20</integer>
		</dict>
	</array>
</dict>
</plist>
1 Like