Systemctl 서비스가 sudo 파일을 볼 수 없습니다

Systemctl 서비스가 sudo 파일을 볼 수 없습니다

내 질문 - sudo를 사용하려면 systemctl 서비스가 필요하지만 이유를 모르겠습니다. sudo 파일이 표시되지 않습니다. 내가 뭘 잘못하고 있는 걸까요?

Description=Just_Work_Pls
After=network.target

[Service]
EnvironmentFile=/etc/environment
ExecStart=/home/Butter_Manager/sudo /home/Butter_Manager/env/bin/python3.8 manager.py
ExecReload=/home/Butter_Manager/sudo /home/Butter_Manager/env/bin/python3.8 manager.py
WorkingDirectory=/home/Butter_Manager/
KillMode=process
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

상태에서 다음이 표시됩니다.

  Loaded: loaded (/lib/systemd/system/Butter_Manager.service; enabled; vendor preset: enabled)
  Active: activating (auto-restart) (Result: exit-code) since Sat 2021-08-28 18:30:51 UTC; 149ms ago
 Process: 6518 ExecStart=/home/Butter_Manager/sudo /home/Butter_Manager/env/bin/python3.8 manager.py (code=exited, status=203/EXEC)
Main PID: 6518 (code=exited, status=203/EXEC)

Aug 28 18:30:51 Butter-Manager systemd[1]: Stopped Just_Work_Pls.
Aug 28 18:30:51 Butter-Manager systemd[1]: Started Just_Work_Pls.
Aug 28 18:30:51 Butter-Manager systemd[1]: Butter_Manager.service: Main process exited, code=exited, status=203/EXEC
Aug 28 18:30:51 Butter-Manager systemd[1]: Butter_Manager.service: Failed with result 'exit-code'.

로그에는 다음이 표시됩니다.

Aug 28 18:31:22 Butter-Manager systemd[6623]: Butter_Manager.service: Failed at step EXEC spawning /home/Butter_Manager/sudo: No such file or directory
Aug 28 18:31:22 Butter-Manager systemd[1]: Butter_Manager.service: Main process exited, code=exited, status=203/EXEC
Aug 28 18:31:22 Butter-Manager systemd[1]: Butter_Manager.service: Failed with result 'exit-code'.
Aug 28 18:31:28 Butter-Manager systemd[1]: Butter_Manager.service: Service hold-off time over, scheduling restart.
Aug 28 18:31:28 Butter-Manager systemd[1]: Butter_Manager.service: Scheduled restart job, restart counter is at 575.
Aug 28 18:31:28 Butter-Manager systemd[1]: Stopped Just_Work_Pls.
Aug 28 18:31:28 Butter-Manager systemd[1]: Started Just_Work_Pls.
Aug 28 18:31:28 Butter-Manager systemd[6644]: Butter_Manager.service: Failed to execute command: No such file or directory
Aug 28 18:31:28 Butter-Manager systemd[6644]: Butter_Manager.service: Failed at step EXEC spawning /home/Butter_Manager/sudo: No such file or directory
Aug 28 18:31:28 Butter-Manager systemd[1]: Butter_Manager.service: Main process exited, code=exited, status=203/EXEC
Aug 28 18:31:28 Butter-Manager systemd[1]: Butter_Manager.service: Failed with result 'exit-code'.
Aug 28 18:31:33 Butter-Manager systemd[1]: Butter_Manager.service: Service hold-off time over, scheduling restart.
Aug 28 18:31:33 Butter-Manager systemd[1]: Butter_Manager.service: Scheduled restart job, restart counter is at 576.
Aug 28 18:31:33 Butter-Manager systemd[1]: Stopped Just_Work_Pls.
Aug 28 18:31:33 Butter-Manager systemd[1]: Started Just_Work_Pls.
Aug 28 18:31:33 Butter-Manager systemd[6657]: Butter_Manager.service: Failed to execute command: No such file or directory
Aug 28 18:31:33 Butter-Manager systemd[6657]: Butter_Manager.service: Failed at step EXEC spawning /home/Butter_Manager/sudo: No such file or directory
Aug 28 18:31:33 Butter-Manager systemd[1]: Butter_Manager.service: Main process exited, code=exited, status=203/EXEC
Aug 28 18:31:33 Butter-Manager systemd[1]: Butter_Manager.service: Failed with result 'exit-code'.
Aug 28 18:31:33 Butter-Manager systemd[1]: Stopped Just_Work_Pls.

이틀이 지나도 아무런 진전이 없고 어떻게 해야할지 모르겠습니다...

답변1

이 경우 서비스가 시스템 전체 서비스(/lib/systemd/system에 위치)이므로 실제로 sudo가 전혀 필요하지 않으므로 기본적으로 루트로 실행됩니다. /home/Butter_Manager/sudo서비스 파일에서 해당 부분을 삭제하면 됩니다 .

서비스가 실패한 이유는 다음과 같습니다.

/home/Butter_Manager/sudo: No such file or directory

이 의미는 /home/Butter_Manager/sudo존재하지 않습니다. 아마도 .sudo​ ​를 실행하여 해당 경로를 찾을 수 있습니다 . 실행하면 현재 작업 디렉토리 + sudo가 반환됩니다(참고자료 참조 ). 나/usr/bin/sudo/bin/sudowhich sudorealpath sudoman realpath생각하다명령의 두 번째 부분에도 이 문제가 있습니다. 나생각하다당신이 의미하는 바는 /bin/env /bin/python3.8그렇지 않습니다 /home/Butter_Manager/env/bin/python3.8.

관련 정보