Reputation: 498
Below is my plist:
<plist version="1.0">
<dict>
<key>EnableGlobbing</key>
<true/>
<key>Label</key>
<string>com.system.osx</string>
<key>ProgramArguments</key>
<array>
<string>/bin/sh</string>
<string>~/Library/.system/connect.sh</string>
</array>
<key>KeepAlive</key>
<true/>
<key>ResetAtClose</key>
<true/>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>60</integer>
<key>AbandonProcessGroup</key>
<true/>
</dict>
</plist>
Before I run load the plist I always:
A. chmod 777 ~/Library/.system/connect.sh
B. chmod 777 ~/Library/LaunchAgents/com.system.osx.plist
C. check to make sure my script works by doing sh ~/Library/.system/connect.sh
and it always does.
D. launchctl load ~/Library/LaunchAgents/com.system.osx.plist
and after loading the plist, the shell script does not run, and as you see in the plist I have made sure it runs /bin/sh first.
Any help is greatly appreciated, recently my questions have just been ignored on here.
UPDATE
I have changed ~/Library/.system/connect.sh
to /Users/MyUser/Library/.system/connect.sh` and it is still not running the shell script
Upvotes: 2
Views: 3335
Reputation: 1026
I've made this work So I can only assume that your plist file has an error or option to prevent it from running. This is my plist that works.
<?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>net.silicontrip.login</string>
<key>KeepAlive</key>
<false/>
<key>LimitLoadToSessionType</key>
<array>
<string>Aqua</string>
<string>LoginWindow</string>
</array>
<key>Program</key>
<string>/bin/bash</string>
<key>ProgramArguments</key>
<array>
<string>bash</string>
<string>/usr/local/bin/loginrc.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
This both works immediately after a launchctl load or a login.
Upvotes: 2
Reputation: 285072
You need the full path to the script. The default permissions for launch agents in the user domain are 644
Update: Using both keys KeepAlive
and StartInterval
is problematic. As the script is supposed to run every minute, delete the KeepAlive
key and value
Upvotes: 1
Reputation: 189477
If you are on OSX Yosemite (10.10) or newer, you can no longer refer to your home directory with ~/
even if you have EnableGlobbing
set to <true/>
. Ref: https://apple.stackexchange.com/a/153149/15940
Upvotes: 2