検索条件
全1件
(1/1ページ)
Pythonでデーモンを作ったので、その手順のメモ
| Env | Ver |
|---|---|
| OS | 2020-05-27-raspios-buster-arm64 |
| Python | 3.7.3 |
| python3-systemd | 234-2+b1 |
sudo apt-get install python-systemd python3-systemd~/foo.pyを以下の内容で作成from systemd import journal
journal.send('Hello world')
journal.send('Hello, again, world', FIELD2='Greetings!', FIELD3='Guten tag')
journal.send('Binary message', BINARY=b'\xde\xad\xbe\xef')
chmod 755 ~/foo.pysudo nano /etc/systemd/system/foo.serviceとして以下の内容を書く[Unit]
Description = Foo
[Service]
ExecStart = python3 /home/pi/foo.py
Restart = always
Type = simple
[Install]
WantedBy = multi-user.target
sudo systemctl enable foo.servicesudo systemctl start foo.servicesystemctl status roomenv.serviceExecStartにsudoを書くと動かない(root権限で動作する模様)