Empty a file without deleting it
empty a log file | truncate a large log file to zero | clear file contents but keep the file | clear error_log | truncate | logs | disk-spaceWarning, destructive. This command deletes, overwrites or changes data in a way that cannot easily be undone. Check every placeholder carefully and make a backup first.
truncate -s 0 -- /var/www/vhosts/example.com/logs/error_logTruncates the file to 0 bytes. Unlike deleting it, the file keeps its owner and permissions, and a service currently writing to it simply keeps writing. The disk space is freed immediately.
Note: The previous content is gone. If it is still needed, copy or compress it first.
Also searched as
- empty a log file
- truncate a large log file to zero
- clear file contents but keep the file
- clear error_log