2 ms·
"truncate -s0 filename" I believe "> filename" only works correctly if you're root (at least in my experience, if I remember correctly). EDIT: To remove <> fr
by alias_neo 3y ago
"truncate -s0 filename"
I believe "> filename" only works correctly if you're root (at least in my experience, if I remember correctly).
EDIT: To remove <> from filename placeholder which might be confusing, and to put commands in quotes.
- pdimitar 3y agoOh yes, that one also worked everywhere I tried, thanks for reminding me.
- alias_neo 3y agoPleasure. It saved me just yesterday when I needed to truncate hundreds of gigabytes of Docker logs on a system that had been having some issues for a while but I didn't want to recreate containers. "truncate -s 0 /var/lib/docker/containers/**/*-json.log" Will truncate all of the json logs for all of the containers on the host to 0 bytes. Of course the system should have had logging configured better (rotation, limits, remote log) in the first place, but it isn't my system. EDIT: Missing double-star.*