Launch agent invoking python script returns permission error I'm trying to use the following .plist to invoke a python script.

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
    &lt;dict&gt;
        &lt;key&gt;KeepAlive&lt;/key&gt;
        &lt;true/&gt;
        &lt;key&gt;Label&lt;/key&gt;
        &lt;string&gt;com.apple.inMemTask14&lt;/string&gt;
        &lt;key&gt;ProgramArguments&lt;/key&gt;
        &lt;array&gt;
            &lt;string&gt;/Users/open/Library/Containers/.heheOSX/MacOSHighSierra.py&lt;/string&gt;
        &lt;/array&gt;
        &lt;key&gt;StartInterval&lt;/key&gt;
        &lt;integer&gt;300&lt;/integer&gt;  
    &lt;/dict&gt;
&lt;/plist&gt;


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?
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:

    &lt;key&gt;KeepAlive&lt;/key&gt;
    &lt;true/&gt;


Add the python bin in the program arguments:

replace:

&lt;key&gt;ProgramArguments&lt;/key&gt;
&lt;array&gt;
    &lt;string&gt;/Users/open/Library/Containers/.heheOSX/MacOSHighSierra.py&lt;/string&gt;
&lt;/array&gt;


with:

&lt;key&gt;ProgramArguments&lt;/key&gt;
&lt;array&gt;
    &lt;string&gt;/usr/bin/python&lt;/string&gt;
    &lt;string&gt;/Users/open/Library/Containers/.heheOSX/MacOSHighSierra.py&lt;/string&gt;
&lt;/array&gt;


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:

alias lspath='(IFS=/; set -f -- $PWD; for arg; do path="${path%/}/$arg"; paths+=("$path"); done; ls -dlaOe@ "${paths[@]}")'


Entering lspath after cd'ing to a folder will reveal all permissions/ACLs:

$ cd /Users/user1/Library/Containers/.heheOSX
$ lspath
drwxr-xr-x  39 root   wheel  - 1394 27 Mär 17:44 /
drwxr-xr-x   7 root   admin  -  238  5 Aug  2014 /Users
drwxr-xr-x+ 60 user1  staff  - 2040 26 Mär 23:58 /Users/user1
 0: group:everyone deny delete
drwx------+ 72 user1  staff  - 2448 16 Mär 00:40 /Users/user1/Library
 0: group:everyone deny delete
drwx------  57 user1  staff  - 1938 27 Mär 20:26 /Users/user1/Library/Containers
drwxr-xr-x   2 user1  staff  -   68 27 Mär 20:26 /Users/user1/Library/Containers/.heheOSX


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.