
systemd
다음 단위 파일이 있습니다
$ cat /etc/systemd/system/myservice.service
[Unit]
Description = My Service
[Service]
ExecStart = /bin/sh -c 'exec /usr/local/bin/myservice [arguments] >>/var/log/myservice/log.log 2>>/var/log/myservice/err.log'
EnvironmentFile = /etc/myservice/config
User = someuser
Group = somegroup
[Install]
WantedBy = multi-user.target
systemd
내 로그 가 꽤 오래되었기 때문에 로그에 대한 리디렉션 형식을 사용하고 있습니다 ( 232
).
이 서비스를 호출하고 싶기 systemd run
때문에 입력하고 있습니다.
sudo systemd-run myservice
Running as unit: run-rac9ffa945b374f2fa8a8273567427005.service
그러나 내 실행 로그에는
a) EnvironmentFile = /etc/myservice/config
전혀 고려되지 않습니다
b) 로그가 생성되지 않습니다./var/log/myservice/
이러한 문제가 의미가 있습니까?
답변1
systemd-run
에 지정된 서비스를 시작하지 않고 /etc/systemd/system/myservice.service
단지 임시 장치에서 실행되기 때문에 해당 장치가 가 아닌 이라고 /usr/local/bin/myservice
불리는 것입니다 .run-rac9ffa945b374f2fa8a8273567427005.service
myservice.service
를 실행하려면 ( 방금 유닛 파일을 작성한 경우 실행 후 ) /etc/systemd/system/myservice.service
를 사용하십시오 .systemctl start myservice.service
systemctl daemon-reload