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

No, you can remove the file and bounce cron. The log file will be recreated.

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.

:cool:

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...

:confused:

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 >> .

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?