[systemd-devel] Redirect logs from script to systemd's StandardOutput file
Lennart Poettering
lennart at poettering.net
Tue Mar 31 14:34:12 UTC 2020
On Do, 12.03.20 14:40, Ani A (aniruddha.a at gmail.com) wrote:
> 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) ?
Please provide the full unit file.
Lennart
--
Lennart Poettering, Berlin
More information about the systemd-devel
mailing list