Skip to content

Instantly share code, notes, and snippets.

@sinewalker
Created July 13, 2018 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sinewalker/4e3d228d6d2124a8bdcec4cf9cb4fffa to your computer and use it in GitHub Desktop.
Save sinewalker/4e3d228d6d2124a8bdcec4cf9cb4fffa to your computer and use it in GitHub Desktop.
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
Copy link
Author

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