Deleting log file


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Deleting log file
# 1  
Old 01-03-2002
Deleting log file

Hi:-

Will there be any difference in Solair 2.6 if I delete /var/cron/log file to free up some space.

Thanks in advance
# 2  
Old 01-03-2002
No, you can remove the file and bounce cron. The log file will be recreated.
# 3  
Old 01-07-2002
better way

Instead of deleting the file, just zero it out by using this concise command.


# > /some/log/file.log

This redirects "nothing" into the file thus erasing the data without removing the file.

Actually you might want to save the last several lines of the file so that you can see the last few days or so. There is a way to cat or tail the last several lines and redirect it to the same logfile, but I just can't remember how to do it. I will find it and resubmit later.



Smilie
# 4  
Old 01-07-2002
Tail command with Solaris is "tail -10 filenamea > filenameb" (10 being the number of lines). With HP you need to use "tail -n10 filenamea > filenameb"

But - having tried tailing a file to it's own name I get an empty file. Fine obviously if I redirect to another name, but causing problem if you tail a file of output to itself.

Any thoughts...

Smilie
# 5  
Old 01-07-2002
You can't redirect output from a file to itself. When the command line is parsed by the shell, the destination file will be zeroed out before output is sent to it. It is allowable to append to the file using >> .
# 6  
Old 01-07-2002
okay - makes sense... no use apending though as you'd just be increasing that log file.

Depends how keen you are to keep the last few entries....if you don't care about that - then you have your answer....if you do - then you could hack it or someone else could explain how to delete the head off a text file?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

deleting lines in a log file

Hello Community, sorry iam from germany and my englisch is not so well. iam searching for less then 4 hours on the web for a solution of my problem. i have a proxy-log-file and want to delete lines wicht matches on two words. example of the line in the logfile: now i want to delet... (3 Replies)
Discussion started by: matze
3 Replies

2. Shell Programming and Scripting

Deleting string within a file that finishes with .log

Hello, This is my first post. Nice forum! I have a file trls.results small exemple of content (actually the file can be very big): ./security/htaccess.htm ./security/ipcount.log ./adhoc/sql/datamod06.sql So there is 3 paths to 3 different files... I want to remove every string that has a... (9 Replies)
Discussion started by: Jacob106106
9 Replies

3. UNIX for Dummies Questions & Answers

Script For Deleting Contents of "Live" Log File

In our shop, we have a situation where a log file from our interface engine software has begun maxing out in file size (reaching the 32-bit "2147483647" limit). Currently, the only way to rectify this is to stop the interface and restart it, which generates a new log. Easy enough, but the... (6 Replies)
Discussion started by: rjhjr64
6 Replies

4. Shell Programming and Scripting

Deleting all characters from 350th character to 450th character from the log file

Hi All, I have a big log file i want to delete all characters (between 350th to 450th characters) starting at 350th character position to 450th character position. please advice or sample code. (6 Replies)
Discussion started by: rajeshorpu
6 Replies

5. Shell Programming and Scripting

deleting double entries in a log file

Hi Folks, I have a apache log file that has double entries (however not all lines appear twice). How can I delete automatically the first line of a double entry? Your help is greatly appreciated. Thanks, Klaus Here is what the log file looks like 217.81.190.164 - - "GET... (7 Replies)
Discussion started by: opusforum
7 Replies

6. Shell Programming and Scripting

Kron Shell: deleting all but most recent log files

I am trying to create a Korn Shell script to be run every 5-10 minute from a crontab. This script needs to look for log files (transaction_<date>.log). If there are more than 5 such files, it needs to delete all but the most current 5. How often these files are create varies - can be every minute... (2 Replies)
Discussion started by: WmShaw
2 Replies

7. Shell Programming and Scripting

command for deleting log files based on some condition

Hello, Can anyone pls. provide me with the command for deleting files older then 15 days with a restriction to keep at least 5 files in a directory even if they are older then 15 days. Any help will be highly appreciated. Thanks, Pulkit (4 Replies)
Discussion started by: pulkit
4 Replies

8. Shell Programming and Scripting

deleting lines in a log file

Is there an easy way to delete the first so many lines in a log file? like I have a log file that has 10000 lines, i want to just get rid of the first 9000. (2 Replies)
Discussion started by: BG_JrAdmin
2 Replies

9. UNIX for Dummies Questions & Answers

deleting 100k log files quickly

I've walked into a while loop gone bad.....which has created 100k+ log files. Is it quicker removing the files with rm pattern* or actually removing the entire directory with rm -rf dir/ It's taking ages (hours) either way ...just curious if one is goig to be quicker than the other...or is it... (8 Replies)
Discussion started by: peter.herlihy
8 Replies

10. UNIX for Dummies Questions & Answers

deleting log files only in particular directories

Hi My problem is i have to remove some log files in specific named directories on a regular basis using shell scripts. What i want my shell script to do is i give the shell script some listing of directories from which to delete all log files recursively. Can anyone please help me. ... (2 Replies)
Discussion started by: sameervs
2 Replies
Login or Register to Ask a Question