I have a log file which is constantly being written to by some process. I need to clear that log file on a daily basis.
The problem is that when I issue this command:
echo "" > logfile.log
the file gets filled with nulls thus increasing the size of the file.
Is there a way to pause/stop the process, then copy the logfile to some name and then clearing the original logfile, then restarting the paused/stopped process?
Send a SIGSTOP signal to the process which you want to pause/stop, copy the log files to target directory and finally issue a SIGCONT signal to the same process.
The problem as stated by you is extras null being inserted in the "log" file could be caused of improper write( ) call to the log file. Check the length of the data being written in the file.