How do I clear a log file that is currently in use?
I'm trying to clear a log file in use, and all the commands I've tried so far:
truncate
less
tail
filenameDon'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.
11 Answer
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.oldOptional: Use Gzip on copy of log
gzip file.log.oldUse
/dev/nullfor clean filecat /dev/null > file.log