简体   繁体   中英

Getting a status 78 launchctl when trying to run a python script with launchd

I am trying to run a python script with launchd on MAC OS X; however, the script is not running. When I check the status code with launchctl, it is status code 78.

<?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.chris.team-drive-table-contents</string>

    <key>WorkingDirectory</key>
    <string>cd ~/Coding\ Scripts/Google\ Apps\ Script/</string>

    <key>ProgramArguments</key>
    <array>
        <string>python</string>
        <string>team_drive_folder_tree.py</string>
    </array>

    <key>StartInterval</key>
    <integer>60</integer>

    <key>RunAtLoad</key>
    <true/>

    <key>KeepAlive</key>
    <true/>
</dict>
</plist>

The script should run every 60 seconds, but it is not running at all.

The below works on my system to call a python file using launchd. If you can call the python file using something like python3 myfile.py in terminal, put the correct path for both python3.7 application and the file. From your example this would mean that you can use terminal to call "python team_drive_folder_tree.py", so you need the path for both of those things and update my code below.

On my computer my version of python3.7 happens to be in my user directory of anaconda so i reference that in the example below. A few other things to note:

filename:com.local.pySched.plist

plist is in the user level LaunchAgents directory

Between your plist tags:

<dict>
    <key>Label</key>
    <string>com.local.pySched</string>
    <key>ProgramArguments</key>
    <array>
        <string>/Users/UsrName/anaconda3/bin/python3.7</string>
        <string>/Users/UsrName/python_work/Schedule_Test.py</string>
    </array>
    <key>StartInterval</key>
    <integer>60</integer> 
    <key>RunAtLoad</key>
    <true/>
</dict>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM