I want to run some long calculation jobs in the background. I choose screen. However I found screen didn't accpet redirection. for examplescreen -dmS name ls>ls.datwon't generate ls.dat.Fortunately, screen -L will output screen's log to a file. However, what it does is to append to previous log file, even if I pkill screen and start a fresh new screen. Is there a way to force it to overwrite the previous log file when starting a new screen?
how to force `screen -L` to overwrite log?
logs;gnu screen
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:%sto 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.