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.

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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.