簡體   English   中英

腳本在啟動時不會產生輸出

[英]Script does not produce output with launched

我創建了一個Python腳本,該腳本可以從命令行正常運行,我使用打印語句顯示一些狀態消息。 當我嘗試使用launchd運行腳本時,不會出現所有打印輸出,但是腳本可以正常運行,因為例如它可以更新sqlite數據庫,而不會出現問題。

我正在使用以下plist文件:

<?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>com.joanba.maslestorres.cat</string>
    <key>ProgramArguments</key>
    <array>
            <string>python</string>
            <string>/maslestorres.cat/jardiNet_datalogger.py</string>
    </array>
    <key>WorkingDirectory</key>
    <string>/maslestorres.cat/</string>
    <key>KeepAlive</key>
    <true/>
    <key>StandardOutPath</key>
    <string>/maslestorres.cat/log/out.txt</string>
    <key>StandardErrorPath</key>
    <string>/maslestorres.cat/log/err.txt</string>
</dict>
</plist>

假定print使用stdout,所以我希望正常輸出到文件/maslestorres.cat/log/out.txt

我做錯了什么?

我已經能夠看到log.txt文件中的輸出只是從python腳本中清除緩沖區。 我一直在添加sys.stdout.flush(),我需要立即查看輸出。 我不清楚的是,為什么在啟動卸載時緩沖區丟失並且沒有寫入日志文件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM