Something I've been wondering is if it's possible to get systemd to start tailing a log file when a unit is brought up, and to send that data into the system journal.

For the sake of discussion, let's say this program logs to a plain text file, and not to stdout. If I had to give an example, a Minecraft server would work.

I know of systemd-cat, but this is just a third party app like logger that doesn't tie into the unit system.

  • Maybe you can get the program to log to a named pipe and arrange for systemd to systemd-cat that named pipe? Jan 13, 2017 at 19:04

1 Answer 1


You could try this in your service unit file:

ExecStartPost=/bin/sh -c 'tail -f /path/to/log | systemd-cat'

It will be somewhat more fragile then the recommended pattern of logging to STDOUT because if the log file is rotated tail won't necessarily be connected the file descriptor again until the service restarted.

There is no built-in function to follow a log file that I'm aware. This is something other logging systems like rsyslog can do.

  • Is it smart enough to kill off the tail when the service is stopped?
    – Mikey T.K.
    Jan 13, 2017 at 16:48
  • Build a simple hello-world unit file and check! Jan 13, 2017 at 16:56
  • 2
    tail's -F follows the file by path name instead of my inode id Aug 2, 2017 at 19:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .