This article (https://news.ycombinator.com/item?id=9793466) makes a case for to sparsely use forking in systemd. Following this advice I try the following python service script:
import time
def run():
with open("/tmp/pysystemd/svc.out","w") as f:
while True:
print("***")
f.write("+++\n")
time.sleep(0.5)
run()
with the following systemd.service script:
[Unit]
Description=Simple zebra service
After=multi-user.target
[Service]
Type=Simple
#ExecStart = /usr/bin/python /tmp/pysystemd/svc.py > /tmp/pysystemd/std.out
ExecStart = /bin/bash -c '/usr/bin/python /tmp/pysystemd/svc.py > /tmp/pysystemd/std.out'
WorkingDirectory = /tmp/pysystemd
[Install]
WantedBy=multi-user.target
Though file /tmp/pysystemd/std.out is created it doesn't contain the expected output... Help appreciated.