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

Andrei Borzenkov arvidjaar at gmail.com
Fri Mar 13 06:17:44 UTC 2020


12.03.2020 12:10, Ani A пишет:
> 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
> 

It is not clear where you are using this command. In one of scripts that
are part of unit definition? In some other script that is run outside of
running unit? In interactive shell session?

> The logs that is written by the script does not appear in the log file!
> Is there anything wrong here (missing something) ?
> 
> --
> Ani
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
> 



More information about the systemd-devel mailing list