This question already has an answer here:
- Empty the contents of a file 1 answer
My log files is very big. Is there a command to empty the content without delete and restore the file? Deleteing and touch is 2 command which is too much typing?
if you want to be more eloquent, will empty
(which is the same as
You can also use
to be perfectly explicit or, if you don't want to,
(applications usually do recreate a logfile if it doesn't exist already).
However, since logfiles are usually useful, you might want to compress and save a copy. While you could do that with your own script, it is a good idea to at least try using an existing working solution, in this case