LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-19-2004, 04:56 AM   #1
philipz
LQ Newbie
 
Registered: Apr 2004
Posts: 25

Rep: Reputation: 0
error emptying syslog file with shell


List,

I have an ever-growing syslog file which I want to flush every hour.
So I schedule a crontab with only the following command:

echo "" > logfile (or "> logfile", which is the same)



Now when I type 'more logfile' after it has been flushed, the output looks like:

^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@

The funny part is that a 'tail logfile' works fine, so I guess that there is something on the first line that causes the shell to interpret it as binary or something (at least not a textfile).

Is there a better way to flush a logfile? Or do I have to add/remove something in the first line of the logfile to make it readable by 'more' again?

Any help is greatly appreciated...

Kind regards,

Phil
 
Old 05-19-2004, 11:08 PM   #2
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
I usually use:
Code:
cp /dev/null <file>
 
Old 05-20-2004, 07:44 AM   #3
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Is there some process that holds the file open while you try to "flush" it?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Grep Syslog - email shell script voodoofxz Linux - Newbie 1 09-06-2005 04:27 PM
decode my syslog file epoo Slackware 6 04-04-2005 06:30 PM
2.6.5 syslog error hemp4fuel Slackware 1 05-02-2004 09:09 AM
2.6.5 syslog error hemp4fuel Linux - General 1 05-02-2004 09:07 AM
Syslog error smokedog Linux - Software 0 02-27-2004 04:33 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration