【问题标题】:Getting a status 78 launchctl when trying to run a python script with launchd尝试使用 launchd 运行 python 脚本时获取状态 78 launchctl
【发布时间】:2019-03-22 22:40:47
【问题描述】:

我正在尝试在 MAC OS X 上运行带有 launchd 的 python 脚本;但是,脚本没有运行。当我用launchctl检查状态码时,它是状态码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>

脚本应该每 60 秒运行一次,但它根本没有运行。

【问题讨论】:

    标签: python launchd launchctl


    【解决方案1】:

    下面在我的系统上使用launchd调用python文件。如果您可以在终端中使用类似 python3 myfile.py 的东西调用 python 文件,请为 python3.7 应用程序和文件输入正确的路径。从您的示例中,这意味着您可以使用终端调用“python team_drive_folder_tree.py”,所以你需要这两件事的路径并在下面更新我的代码。

    在我的计算机上,我的 python3.7 版本恰好位于我的 anaconda 用户目录中,因此我在下面的示例中引用了它。其他需要注意的事项:

    文件名:com.local.pySched.plist

    plist 在用户级 LaunchAgents 目录中

    在您的 plist 标签之间:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-10
      • 2011-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多