I am regularly doing a long running (~5 day) data processing programme. I'm using Ubuntu and running the command with a systemd transient task via systemd-run --unit data_import /path/to/my-script.sh
. It's working well. I can look at the logging standard output of the script with journalctl -u data_import.service
.
I would like the stdout (& stderr) from the script to be saved to a file as well as the systemd journal. I see that systemd-run --unit data_import -p "StandardOutput=file:/path/my-logging-file.txt …
will save stdout to that file. However it won't log to the journald. I tried to provide the argument twice systemd-run -p "StandardOutput=file:/path/my-logging-file.txt" -p "StandardOutput=journal" …
, but that didn't work.
Is it possible with systemd to log the stdout to a file and to the systemd journal? (likewise for stderr?)
Ubuntu 18.04 & 20.04, systemd v250. or v245 etc