root@raspberrypi:~# systemctl status mydaemon.service -l ● mydaemon.service - This is my daemon Loaded: loaded (/etc/systemd/system/mydaemon.service; enabled) Active: failed (Result: exit-code) since 木 2017-02-09 17:01:27 JST; 1s ago Process: 1587 ExecStart=/root/hoge_task/hoge_task.sh (code=exited, status=203/EXEC) Main PID: 1587 (code=exited, status=203/EXEC) 2月 09 17:01:27 raspberrypi systemd[1]: Started This is my daemon. 2月 09 17:01:27 raspberrypi systemd[1]: mydaemon.service: main process exited, code=exited, status=203/EXEC 2月 09 17:01:27 raspberrypi systemd[1]: Unit mydaemon.service entered failed state.
systemctl statusを見てもエラーの原因はわかりません。こういうときはsyslogを見ます。
$ less /var/log/syslog (略) Feb 9 14:20:57 raspberrypi systemd[416]: Failed at step EXEC spawning /root/hoge_task/hoge_task.py: Permission denied
Permission denied...権限がないと言われています。
確認してみるとhoge_task.shの権限は644でした。実行権限を与えます。
$ chmod 744 /root/hoge_task/hoge_task.sh
再度チャレンジ。
$ systemctl start mydaemon $ systemctl status mydaemon ● mydaemon.service - This is my daemon. Loaded: loaded (/etc/systemd/system/mydaemon.service; enabled) Active: active (running) since 木 2017-02-09 17:07:56 JST; 7min ago Main PID: 416 (hoge_task)
成功しました。
デーモンのエラーはとりあえずsyslogを見ましょうという教訓でした。