I have a housekeeping Fake build that I'd like to run every hour. My build runs fine from the CLI with fake run, but when I try to use it from launchd, it outputs "Error while parsing command line, usage is: etc."
My Housekeeping.plist looks like this:
<?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>EnvironmentVariables</key>
<dict>
<key>DOTNET_CLI_HOME</key>
<string>/Users/larryobrien</string>
</dict>
<key>InitGroups</key>
<true/>
<key>Label</key>
<string>CheckDoing</string>
<key>ProgramArguments</key>
<array>
<string>/Users/larryobrien/.dotnet/tools/fake</string>
<string>run</string>
</array>
<key>StandardErrorPath</key>
<string>CheckDoing.err</string>
<key>StandardOutPath</key>
<string>CheckDoing.out</string>
<key>StartCalendarInterval</key>
<array>
<dict>
<key>Minute</key>
<integer>0</integer>
</dict>
</array>
<key>WorkingDirectory</key>
<string>/Users/larryobrien/src/Housekeeping</string>
</dict>
</plist>
Not sure if this is an SO question or a Superuser question, but since I think it boils down to a familiarity with Fake, I'm going to try it here.
Related
Here is my file, I am not getting anything logged, although the loading is apparently successful, as I can see it running with the list command;
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.whtDaily.gexUW</string>
<key>ProgramArguments</key>
<array>
<string>/Users/x/Dropbox/ai/getData.sh</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>22</integer>
<key>Minute</key>
<integer>15</integer>
</dict>
<key>RunAtLoad</key><true/>
<key>StandardErrorPath</key>
<string>/Users/x/Dropbox/ai/logs/daily.err</string>
<key>StandardOutPath</key>
<string>/Users/x/Dropbox/ai/logs/daily.out</string>
</dict>
</plist>
I am also not clear if I need to running 'start' after load, or does that happen automatically since I have the 'RunAtLoad' key set to true? I have tried calling start after load, and not with no luck.
This plist file is in the /Library/LaunchAgents directory and I am calling with load and unload with sudo.
The sh file was not executable.
chmod +x getData.sh
did the trick.
I've made an Automator app that finds people that has birthdays on a given day and saves the names of those in a text-file. It runs in a bash script that also alerts me when someone has a birthday. This works fine when i initiate the script from terminal. But when it runs through my ~/Library/LaunchAgents the birthday list is always empty. Does anybody have a clue, what could be the cause of this?
this is my agent-script
<?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>dk.emmajohnsen.birthdaygreetings</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>/Users/Emma/Projects/scripts/project_happy_birthday/orchestrateBirthdayAlert</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>08</integer>
<key>Minute</key>
<integer>17</integer>
</dict>
</dict>
</plist>
I'm current trying to set up my program as a scheduled task in OSX. I tried setting up a plist file for launchd after compiling with the mix using escript.build.
However, OSX simply ignores running my program even though launchd says it's "Loaded".
If I try to execute the program in a terminal it runs fine. Here is what my plist file looks like
<?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>EnableGlobbing</key>
<false/>
<key>Label</key>
<string>com.plisterine.test</string>
<key>LowPriorityIO</key>
<false/>
<key>Nice</key>
<integer>0</integer>
<key>ProgramArguments</key>
<array>
<string>/Users/Lee1/Documents/flower_power_data_dump/flower_power_data_dump</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>14</integer>
<key>Minute</key>
<integer>20</integer>
</dict>
</dict>
</plist>
I need to run an mac app daily without any user interaction using launchd, i created a .plist file and pasted it in /system/LaunchDaemons and after that how to execute the plist file, can any one please tell me the step by step working process on how to work with launchd it will helpful for me, I pasted my .plist file below.
<?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>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>myapp.restart</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/myapp.app</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>16</integer>
<key>Minute</key>
<integer>40</integer>
</dict>
</dict>
</plist>
You'll probably need the name of your program like this rather than ProgramArguments:
<key>Program</key>
<string>/Applications/myapp.app/Contents/MacOS/myapp</string>
I need to open my application and run a specific task from that application automatically in a given time. So I searched in google and came up with launchd. First question, Is this is correct choice?
I have created a plist and I kept that in the location ~/Library/LaunchAgents/fileName.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.companyname.example</string>
<false/>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>mac_1</string>
<key>Program</key>
<string>open</string>
<key>ProgramArguments</key>
<array>
<string>Argument_1</string>
<string>Argument_2</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Day</key>
<integer>1</integer>
<key>Hour</key>
<integer>10</integer>
<key>Minute</key>
<integer>41</integer>
<key>Month</key>
<integer>8</integer>
<key>Weekday</key>
<integer>3</integer>
</dict>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
The Problem with this is, It is working only when the computer will restarted, otherwise it will not be invoked. So, My Second question when the launchd will register for the events ?
There is a utility called "launchctl"
You need to use it to load your plis file into launchd.
Type: launchctl load plist_file.
If you want to schedule something from your application - one way would be calling "system" to execute launchtl utility. There is also undocumented API for launchd but I couldn't find a way to use it for scheduling.
launchd would be the easiest way to schedule something on the system, as it has reach scheduling properties.