I'm trying to use the following .plist
to invoke a python 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>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.apple.inMemTask14</string>
<key>ProgramArguments</key>
<array>
<string>/Users/open/Library/Containers/.heheOSX/MacOSHighSierra.py</string>
</array>
<key>StartInterval</key>
<integer>300</integer>
</dict>
</plist>
For some reason when I execute:
launchctl load -w /Users/open/Library/LaunchAgents/com.apple.inMemTask14.plist
I get the following errors in my system.log:
Mar 27 11:39:19 openZ-MacBook-Pro com.apple.xpc.launchd[1] (com.apple.inMemTask14): This service is defined to be constantly running and is inherently inefficient.
Mar 27 11:39:19 openZ-MacBook-Pro com.apple.xpc.launchd[1] (com.apple.inMemTask14[1335]): Could not find and/or execute program specified by service: 13: Permission denied: /Users/open/Library/Containers/.heheOSX/MacOSHighSierra.py
Mar 27 11:39:19 openZ-MacBook-Pro com.apple.xpc.launchd[1] (com.apple.inMemTask14[1335]): Service setup event to handle failure and will not launch until it fires.
I have given execute permission to the python script. Is there something wrong with my .plist
? How can I fix the errors displayed in the logs?
Best Answer
You have one error and a minor one in your plist and probably one inconsistency in your file system:
Keeping a job alive no matter what and starting the same job every 5 minutes is like being forced to stay in the bathroom and going to the bathroom every five minutes because of ... an ablutomania.
So remove the part:
Add the python bin in the program arguments:
replace:
with:
If you prefer another python bin (e.g. some brew/python), use this one instead.
Finally make sure that the logged in user (i.e. the one launching the agent) has at least read access to /Users/open/Library/Containers/.heheOSX/MacOSHighSierra.py!
Regarding the last problem:
I use the following alias in my .bash_profile to get all permissions/ACLs of a path:
Entering lspath after cd'ing to a folder will reveal all permissions/ACLs:
In this example no other user except user1 (and root) will be able to launch/load a *.py in /Users/user1/Library/Containers/.heheOSX because other users can't traverse neither /Users/user1/Library nor /Users/user1/Library/Containers because of their restrictive drwx------ permissions.