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

Using cat/cp command

cat /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

Bài đăng phổ biến từ blog này

Phân trang- FIFO, LRU, OPT

Chuyển đổi địa chỉ vật lý và địa chỉ ảo trong bộ nhớ chính

Chuyển Ubuntu sang phân vùng mới