The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Checking for a file in file pattern before deleting it dsrookie UNIX for Dummies Questions & Answers 1 05-09-2008 01:29 PM
Deleting lines inside a file without opening the file toms Shell Programming and Scripting 3 09-24-2007 04:58 AM
deleting file that isn't really there LisaS UNIX for Dummies Questions & Answers 4 07-08-2007 01:22 AM
Remove the contents of a file without deleting the file sumesh.abraham Shell Programming and Scripting 10 12-02-2006 02:35 PM
Deleting a file I don't own kumachan UNIX for Dummies Questions & Answers 5 09-19-2003 07:50 AM

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-03-2002
Registered User
 

Join Date: Nov 2001
Posts: 52
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
Forum Sponsor
  #2  
Old 01-03-2002
Registered User
 

Join Date: Nov 2001
Posts: 60
No, you can remove the file and bounce cron. The log file will be recreated.
  #3  
Old 01-07-2002
Kelam_Magnus's Avatar
Registered User
 

Join Date: Aug 2001
Location: DFW McKinney, TX,
Posts: 1,069
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.



__________________
My brain is your brain
  #4  
Old 01-07-2002
Registered User
 

Join Date: Nov 2001
Location: New Zealand
Posts: 333
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...

__________________
Pete
  #5  
Old 01-07-2002
Registered User
 

Join Date: Nov 2001
Posts: 60
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
Registered User
 

Join Date: Nov 2001
Location: New Zealand
Posts: 333
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?
__________________
Pete
Google The UNIX and Linux Forums
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:58 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0