This question already has an answer here:
- Empty the contents of a file 1 answer
Currently my log files get very big. Is there a command to empty the files without delete and restore it? It involves 2 command which is sometimes taking too long.
if you want to be more eloquent, will empty
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