Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ticktock systemd service
[Unit]
Description=ticktock
AssertPathExists=/home/mjl
[Service]
WorkingDirectory=/home/mjl
#unbuffered:
ExecStart=/usr/bin/python -u /home/mjl/ticktock.py
#buffered:
#ExecStart=/home/mjl/ticktock.py
StandardOutput=file:/tmp/ticktock.log
StandardError=inherit
Restart=always
RestartSec=3
[Install]
WantedBy=default.target
@sinewalker

This comment has been minimized.

Copy link
Owner Author

@sinewalker sinewalker commented Jul 13, 2018

See ticktock.py for an example of what this runs.

This demonstrates how Python's buffering of output means that systemd journal (or even just straight streaming to a text file) will not update immediately unless you tell Python not to buffer (with the -u switch).

Also see this Stack Exchange question

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment