Have you ever wanted to truncate a log file that was being written to by a running process without stopping the process to do so?
If so then all you need is the following to clear out the active log file:
Technorati Tags: Truncate, Log, File, Ubuntu, Linux, Andrew Beacock
If so then all you need is the following to clear out the active log file:
cat /dev/null > some_log_file.logThere are some other great tips over on the Bash Cures Cancer blog.
Technorati Tags: Truncate, Log, File, Ubuntu, Linux, Andrew Beacock
Comments
(colon greater-than filename) is a much shorter syntax :)
cat /dev/null > /path/unnecessary-long-file.dv
Thanks for the tip!
and hey presto -- the backup moved on to the next file, and I didn't break the cp command (which would be very hard to resume) (yes, I hear that rsync is a better way of doing this, I'll check it for next time)
truncate -s0 some_log_file.log