Categories

فروری 2019
پیرمنگلبدھجمعراتجمعہہفتہاتوار
 123
45678910
11121314151617
18192021222324
25262728 
Linux

How to clean a log file in Linux?

Emptying a log file in Linux

How to clean a log file in Linux? – Over time it gets necessary to truncate log files. Expanding log files may not be easy to read. In Linux emptying a log file is easily achieved by issuing some basics commands. To remove or truncate a file, we can use /dev/null, which is utilized to discard text.

Be sure NOT to clean ANY file. Some files may be needed and should not be truncated.

To truncate or clean up a log file, do following:

[su_note]linux# cat /dev/null > [logfle] [/su_note]

You can use alternative methods to achieve same result:

[su_note]linux# : > [logfile] (: is semicolon)[/su_note] [su_note]linux# true > [logfile][/su_note] [su_note]linux# cp /dev/null [logfile][/su_note] [su_note]linux# dd if=/dev/null of=[logfile][/su_note] [su_note]linux# echo “” > [logfile][/su_note]

 

Pegham Logo Retina

About the author

pgadmin

Masood

Add Comment

Click here to post a comment

Discover more from Pegham

Subscribe now to keep reading and get access to the full archive.

Continue reading

Pegham

FREE
VIEW