Empty or delete large log file in Linux
Empty or delete large log file in Linux
Assuming we have a log file name log.txt. It is beginning too big and you want to delete/empty content of this file.Directing to null
> log.txt
Using "true" command redirection
: > log.txt
#or
true > log.txt
#or
true > log.txt
Using cat/cp command
cat /dev/null/ > log.txt
#or
cp /dev/null/ > log.txt
#or
cp /dev/null/ > log.txt
Using "echo" command
echo "" > log.txt
Using truncate command
-s flag set size of file
truncate -s 0 log.tst
Nhận xét
Đăng nhận xét