This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
I'm trying to run iperf
as a service and log its output to a normal file in /var/log
. Here is my unit file:
[Unit]
Description=iPerf TCP Server
After=network-online.target
[Service]
User=iperf
Restart=always
ExecStart=/usr/bin/iperf --server --window 132k --interval 2 --port 5001
StandardOutput=file:/var/log/iperf-tcp.log
StandardError=inherit
[Install]
WantedBy=multi-user.target
The problem I'm having is that if the service is started (or restarted) while the log file has non-zero size, the log file never gets overwritten. But if I truncate the file to zero bytes and restart the service, it starts writing again until the next time the service is restarted.
I noticed the man page for systemd says the following:
https://www.freedesktop.org/software/systemd/man/systemd.exec.html#StandardOutput=
If
path
refers to a regular file on the filesystem, it is opened (created if it doesn't exist yet) for writing at the beginning of the file, but without truncating it.
So one, what is the point of writing at the beginning of a file if it's not been truncated? And two, more importantly, what can I do to get systemd to truncate the log file?
I am running Ubuntu 18.04, which is running systemd 237, and so it does not have the append
option.
Subreddit
Post Details
- Posted
- 4 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/systemd/com...