2017-10-17 8 views
0

내가 파이썬 스크립트를 다음과 같이이 작동하지 않습니다 테스트를 시작 systemctl와 sudo I 활성을리눅스 출력 재 지정 데몬은

[Unit] 
Description=Un service de test. 

[Service] 
Type=idle 
ExecStart=/usr/bin/python3 /home/andy/Desktop/test.py > /home/andy/Desktop/test.log 2>&1 

[Install] 
WantedBy=multi-user.target 

그리고 :

while True: 
    print("ok") 

나는 데몬 test.service를 만들었습니다. 서비스. 로그 파일이 만들어지지 않습니다. 출력 리디렉션이 작동하지 않습니다. 내가 systemctl 상태 test.service를 쓸 때

, 내가 가진 :

● test.service - Un service de test. 
    Loaded: loaded (/etc/systemd/system/test.service; disabled; vendor preset: enabled) 
    Active: active (running) since Wed 2017-10-18 00:50:29 CEST; 20s ago 
Main PID: 3651 (python3) 
    Tasks: 1 (limit: 4915) 
    CGroup: /system.slice/test.service 
      └─3651 /usr/bin/python3 /home/andy/Desktop/test.py > /home/andy/Desktop/test.log 2>&1 

oct. 18 00:50:29 andy-G551JW systemd[1]: Started Un service de test.. 
oct. 18 00:50:29 andy-G551JW python3[3651]: ok 
oct. 18 00:50:29 andy-G551JW python3[3651]: ok 

가 어떻게 데몬 스크립트의 출력을 리디렉션 할 수있다?

+0

가능한 한 [python-daemon and stdout] (https://stackoverflow.com/questions/11146128/python-daemon-and-stdout) 중복 가능 – jww

답변

1

출력을 리디렉션하지 마십시오. 스크립트를 표준 출력으로 인쇄하십시오. Systemd는 출력을 journalctl -u test 또는 systemctl status test으로 볼 수있는 systemd 저널에 저장합니다.

+0

잠시 동안 "확인"이 2 번 있습니다. True : print (" 승인"). 정상입니까? – Andy