Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

I'm trying to clear a log file in use, and all the commands I've tried so far:


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.

share|improve this question
Which log file, and what was the error message? –  George Bailey Aug 18 '12 at 19:46

1 Answer 1

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
share|improve this answer
Simply > file.log should be enough. No need for cat /dev/null. –  muru Oct 12 '14 at 16:45
Thanks, I try remember it for next. ;-) – Oct 12 '14 at 17:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.