Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

How to truncate the redirect log output file in Linux?

I have a program running all the time and redirect the stderr output to a log file.

spark-submit --master local[*] --class my.spark.streaming.program 2>file.log &

Now that the file.log size has exceeded 2GB.

I want to empty it(clear only previous data, retain future data), but the program can't be interrupted.


I used the following command and found that the front of the file was filled with 0x00, but the file size has not changed.

echo "" > file.log

Is there any way to make the running program reset the offset of the file file.log write?

Comments