I don't believe you can force screen to overwrite the log. It logs to screenlog.%n
by default, where %n
is the screen window number (so each window has it's own log). If that file exists, it appends to it.
However, you can tell screen
to use a different filename, including a timestamp, so you'll get a new log file each time, but you'll then need to manage the old logs.
In .screenrc
you can put the following line,
logfile /path/to/log/screenlog-%n-%Y%m%d-%c:%s
to create log files that include the window number (%n
) and the year, month, date, and time.
Alternatively, you could create a bash
alias that deletes the log file before running screen, for example,
alias screen='rm /path/to/log; screen'
If you want to affect screen
log files in the current directory, just remove /path/to/log/
from the commands above.
Lastly, depending on what you're trying to achieve, the Linux tool script
might be more useful than just logging in screen
. man script
for more information.
screen -dmS xxx ls>ls.dat
– user15964 Apr 30 '16 at 05:27screen
doesn't send output tostdout
in that way, so you can't redirectscreen
's output, that's why it has a logging option. – EightBitTony Apr 30 '16 at 05:34