I am trying to set an application (*.app) to run at startup in MAC OS Sierra. I know that a plist has to be added to the following folder,
/Library/LaunchAgents
I created a plist with the code below. It needs to run as admin at startup every time MAC OS is loaded. But it is not working. The app does not start at startup. How to make the app work at startup?
<?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>com.myapp.startup</string>
<key>Program</key>
<string>/Applications/myapp.app/Contents/MacOS/myapp</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
<key>LaunchOnlyOnce</key>
<true/>
<key>StandardOutPath</key>
<string>${installdir}/startup.stdout</string>
<key>StandardErrorPath</key>
<string>${installdir}/startup.stderr</string>
<key>UserName</key>
<string>admin</string>
<key>GroupName</key>
<string>admin</string>
<key>InitGroups</key>
<true/>
</dict>
</plist>
Related
MI have just installed Grav locally and would like it to run as a daemon. Apparently on Macs that's done in ~/LauchAgents
I have tried to setup the .plist but it's not working. As I am new to Macs I wondered if anyone knew how to setup a local service? Here is what I have so far...
<?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>grav</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/php</string>
<string>~/grav/php -S system/router.php</string>
<string>--httpListenAddress=127.0.0.1</string>
<string>--httpPort=8000</string>
</array>
<key>RunAtLoad</key>
<true/>
</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>
Launch daemon worked as it should but now the problem is it keeps loading the same shell script and I can see multiple entries for the same rule. sudo ipfw list. How can this be prevented?
<?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.apple.ipfw</string>
<key>OnDemand</key>
<false/>
<key>ProgramArguments</key>
<array>
<string>/usr/local/ipfw.apple.startup.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceDescription</key>
<string>Apple IPFW Filter Rules</string>
<key>StandardErrorPath</key>
<string>/var/log/ipfw.apple.stderr</string>
<key>StandardOutPath</key>
<string>/var/log/ipfw.apple.stdout</string>
<key>UserName</key>
<string>root</string>
</dict>
Use LaunchOnlyOnce key in plist file.
LaunchOnlyOnce :
This optional key specifies whether the job can only be run once and only once. In other words, if the
job cannot be safely respawned without a full machine reboot, then set this key to be true.
I am trying to develop a Mac LaunchAgent and am testing with this, which should start the console:
<?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>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.depthmine.test</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/Utilities/Console.app/Contents/MacOS/Console</string>
</array>
</dict>
</plist>
The file appears to load (no errors in the Terminal) but the console does not start and there does not seem to be a process in Terminal either. I also tried a PHP script and that didn't start either.