Clear Error Log Unix
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the
Linux Error Log
company Business Learn more about hiring developers or posting ads with us Unix & Linux solaris error log Questions Tags Users Badges Unanswered Ask Question _ Unix & Linux Stack Exchange is a question and answer site for users of Linux,
Ubuntu Error Log
FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the sql error log top cat /dev/null emptied my log file but size did not change up vote -1 down vote favorite 1 I'm quite new to Unix. Using Solaris 10 I faced the below issue. There is a large log file with size 9.5G. I tried to empty the file using the below command. # cat /dev/null file_log.txt By doing this I regained space on the file system but the size of the file still shows the same and windows error log is increasing. I figured a process is still running into the log file. Is there a way to correct the file size? Is this going to effect my file system? files logs io-redirection cat share|improve this question edited Jul 28 '14 at 22:45 Gilles 369k676711120 asked Jul 28 '14 at 18:17 user78960 1111 5 Did you mean to write cat /dev/null > file_log.txt? –user000001 Jul 28 '14 at 18:25 1 What do ls -l file_log.txt and du file_log.txt say? –Cristian Ciupitu Jul 28 '14 at 18:25 3 Do you try to restart the service? –cuonglm Jul 28 '14 at 18:26 I'm sorry people! I meant cp /dev/null file_log.txt –user78960 Jul 29 '14 at 19:13 But anyway, now I can make sense with the below answers what could have gone wrong. The process was still writing to the file when I ran the cp command. Thanks anyway! –user78960 Jul 29 '14 at 19:15 add a comment| 3 Answers 3 active oldest votes up vote 5 down vote Assuming you meant to say cat /dev/null > file_log.txt the answer is that the process that has the file open for writing did so without O_APPEND, or it sets the offset into the file arbitrarily, in which case a sparse file is created. This is a file that contains "holes", i
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site
Oracle Error Log
About Us Learn more about Stack Overflow the company Business Learn more about debian error log hiring developers or posting ads with us Super User Questions Tags Users Badges Unanswered Ask Question _ Super User
Apache Error Log Path
is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer http://unix.stackexchange.com/questions/147044/cat-dev-null-emptied-my-log-file-but-size-did-not-change The best answers are voted up and rise to the top How do erase the contents of a error.log file but keep the file intact up vote 16 down vote favorite 6 I want to erase the contents of the file error.log (nginx error log file), but I don't want to actually delete the file. is this possible? running ubuntu ubuntu logging nginx share|improve this question http://superuser.com/questions/218214/how-do-erase-the-contents-of-a-error-log-file-but-keep-the-file-intact asked Dec 4 '10 at 3:02 user27449 1,655174475 add a comment| 2 Answers 2 active oldest votes up vote 37 down vote You can use this: >error.log (typed just like that - an empty output redirection) or truncate -s0 error.log share|improve this answer answered Dec 4 '10 at 3:16 Dennis Williamson 57.5k10101136 @Ignacio: If the file already exists, either will truncate it. If the file doesn't exist, either will create it. –Dennis Williamson Dec 4 '10 at 3:21 You're right, my bad. –Ignacio Vazquez-Abrams Dec 4 '10 at 3:24 The last option worked for me, for some reason sudo >error.log didnt work for me (ubuntu 12.04) –davidkonrad May 19 '14 at 10:38 3 @davidkonrad: You would have to already be root for the redirection to work since it's performed before sudo takes effect. Or you can do sudo bash -c '>error.log' –Dennis Williamson May 19 '14 at 10:56 OK, didnt knew that. Thank you for clarification! –davidkonrad May 19 '14 at 11:01 add a comment| up vote 1 down vote You'll confuse the daemon. Erase the file then send SIGHUP to nginx. share|improve this answer ans
do I truncate or shrink large text file under UNIX / Linux operating systems? There are various tools and methods to truncate large text files http://www.cyberciti.biz/faq/truncate-large-text-file-in-unix-linux/ under UNIX / Linux operating systems as follows.
Options #1: Shell Output RedirctionYour can truncate text file and make the size to zero using redirection:> {filename} ls -l largefile.txt > largefile.txt ls -l largefile.txtPlease note that largefile.txt file is created if it doesn't exist. And largefile.txt file is overwritten if it exists.Option #2: truncate CommandUse the truncate command to error log shrink or extend the size of each FILE to the specified size:truncate -s 0 {filename.txt} ls -lh filename.txt truncate -s 0 filename.txt ls -lh filename.txtThe -s option is used to set SIZE to zero. See truncate command man page for more details: man truncateOption #3: logrotate Utilitylogrotate command is designed to ease administration of systems that generate large numbers clear error log of log files. It allows automatic rotation, compression, removal, and mailing of log files. Each log file may be handled daily, weekly, monthly, or when it grows too large. See how to use logrotate command to rotates, compresses, and mails system logs stored in /var/log and other locations under UNIX / Linux oses.Option #4: /dev/nullThe null device /dev/null act as the black hole that discards all data written to it under Unix like operating system. You can use it as follows (hat tip to Philippe Petrinko):cp /dev/null largefile.txtORcat /dev/null > largefile.txt Share this tutorial on:TwitterFacebookGoogle+Download PDF version Found an error/typo on this page?About the author: Vivek Gite is a seasoned sysadmin and a trainer for the Linux/Unix & shell scripting. Follow him on Twitter. OR read more like this:Truncate: UNIX Binary Log FileDelete a log files in Linux or UNIXHow To Limit The Growth Of UNIX / Linux Log FilesHow do I rotate log files?Linux / UNIX: Create Large 1GB Binary Image File With dd CommandUnix and Linux: Redirect Error Output To null CommandFinding a F