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:

linux# cat /dev/null > [logfle]

You can use alternative methods to achieve same result:

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

 

Pegham Logo Retina

About the author

Masood

ایک پردیسی جو پردیس میں رہنے کے باوجود اپنے ملک سے بے پناہ محبت رکھتا ہے، اپنے ملک کی حالت پر سخت نالاں ہے۔ ایک پردیسی جس کا قلم مشکل ترین سچائی لکھنے سے باز نہیں آتا، پردیسی جسکا قلم اس وقت لکھتا ہے دل درد کی شدت سے خون گشتہ ہو جاتا ہے اور اسکے خونِ جگر کی روشنائی سے لکھے ہوئے الفاظ وہ تلخ سچائی پر مبنی ہوتے ہیں جو ہضم مشکل سے ہوتے ہیں۔۔۔ مگر یہ دیوانہ سچائی کا زہر الگنے سے باز نہیں آتا!

Add Comment

Click here to post a comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Pegham Network Community

FREE
VIEW