DEV Community

Discussion on: Linux - I am Love with Terminal

Collapse
 
louislow profile image
Louis Low

When a file size increasing overtime, use truncate, but without changing anything to the file permission and other stuff that applied to it. Best with adding it to crontab.

-s is set limit file size e.g. 1024k

$ truncate -s 1024k /var/log/kern.log
Collapse
 
vlasales profile image
Vlastimil Pospichal

Unfortunately, this shortens the end of the file, which reduces its usability.

Collapse
 
louislow profile image
Louis Low

Luckily, you can set limit the file size.

Thread Thread
 
vlasales profile image
Vlastimil Pospichal

When logging in, I am not interested in the beginning of the file, but mainly its end. Every time I cut it off, logging loses its meaning.

Thread Thread
 
louislow profile image
Louis Low

You are right. For user does not care about the logging but just want to reduce the file size (a couple of gigabytes). This is useful.

Some comments have been hidden by the post's author - find out more