[systemd-devel] Redirect logs from script to systemd's StandardOutput file

Ani A aniruddha.a at gmail.com
Thu Mar 12 09:10:57 UTC 2020


Hello,

I am on Ubuntu 18.04.2, and I have systemd version 237. I have some common tasks
which need to happen prestart and poststop which I have moved to a
script. All unit
files look like:

    StandardOutput=file:/var/log/my-<unitname>.log
    ExecStartPre=/path/to/helper.sh -t prestart -u <unitname>
    ExecStopPost=/path/to/helper.sh -t poststop -u <unitname>
    ExecStart=/path/to/my/exe

where <unitname> is the name of the systemd unit file.

I use systemd's directive to log stdout to file, and in the prestart
and poststop actions also
I try to write some logs to the same file with shell echo, like:

    echo "..." >> /var/log/my-<unitname>.log

The logs that is written by the script does not appear in the log file!
Is there anything wrong here (missing something) ?

--
Ani


More information about the systemd-devel mailing list