2013-10-18 5 views
0

명령 줄에서 올바르게 작동하는 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> 

인쇄 그래서 난 정상 출력이 /maslestorres.cat/log/out.txt을 제기가는 것으로 기대 표준 출력 사용하는 가정입니다.

내가 뭘 잘못하고있어?

답변

0

파이썬 스크립트에서 버퍼를 그냥 플러시하는 log.txt 파일의 결과를 볼 수있었습니다. sys.stdout.flush()를 추가하여 출력 결과를 즉시 확인해야했습니다. 나에게 명확하지 않은 점은 launchd 언로드 시간에 버퍼가 손실되어 로그 파일에 기록되지 않는 이유입니다.

관련 문제