0

I wrote a simple python3 skript and want to make a service from it. Here are the two files

#!/bin/python3
while True:
     print('True')

Systemd Service:

[Unit]
Description=True Service

[Service] Type=simple ExecStart=python3 /root/print_true.py StandardOutput=journal+console

[Install] WantedBy=multi-user.target

The service is starting but i cant see the output anywhere. Not in journalctl -u true-service.service, not in systemctl status true-service and not in syslog. I want to have it only in journal but how can i accomplish that? I cant seem to find a working answer.

Nico
  • 123

1 Answers1

0

Use systemd-cat to accomplish that, pipe the output to it.

Test it:

echo "hello world" | systemd-cat -ttrue-service

List the output:

journalctl -t true-service

Change your service unit:

ExecStart=/usr/bin/python3 /root/print_true.py | /usr/bin/systemd-cat -ttrue-service

Michael D.
  • 2,830