Celeb Glow
general | March 31, 2026

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
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.

1

1 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. ;-)

  1. Optional: Copy log file

    cp file.log file.log.old
  2. Optional: Use Gzip on copy of log

    gzip file.log.old
  3. Use /dev/null for clean file

    cat /dev/null > file.log
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy