How do I clear a log file that is currently in use?
12,338
Are there many methods how clear/delete log files. Some of log you can delete, some not and some you can truncate.
For linux system log (such as mail.log for example) I use this method. Steps 1 and 2 are optional, but sometines you need check older logs and backup is sometimes useful. ;-)
Optional: Copy log file
cp file.log file.log.old
Optional: Use Gzip on copy of log
gzip file.log.old
Use
/dev/null
for clean filecat /dev/null > file.log
Related videos on Youtube
Author by
Dreamracer
Updated on September 18, 2022Comments
-
Dreamracer over 1 year
I'm trying to clear a log file in use, and all the commands I've tried so far:
truncate less tail filename
Don't get the job done. Deleting the file and creating a new file with the same name doesn't work either.
I heard about a config-file for the log but I have no idea where this is kept. Is there ANY way to fix this problem? This log file will get so big it'll crash my system.
-
joeguarino over 11 yearsWhich log file, and what was the error message?
-