I frequently need to truncate log files. Instead of deleting the file, re-creating the file and then re-setting permissions, I have two ways I've learned to leave the file "as is" but remove all the data.
Method 1: Truncate the size to zero
sudo -u mysql truncate -s 0 file_name
Method 2: Write "nothing" to the file
sudo -u mysql cat /dev/null > file_name
Generally method 1 is preferred because it requires fewer permissions to do that.
No comments:
Post a Comment