Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to empty log file

Posted on 2004-09-07
4
Medium Priority
?
581 Views
Last Modified: 2013-12-15
I'm quite new to linux, and was wondering what is the best way to empty / archive a log file.

The file in question is /var/log/messages

I tried:

mv /var/log/messages /var/log/messages.archive.07-09-2004
touch /var/log/messages    to create new empty log file

but now nothing is being written to the logfile! How can I fix this and how should I have done it?

Thanks.
0
Comment
Question by:mcwalters
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
liddler earned 150 total points
ID: 11996847
Usually messages log is rotated by a cronjob in roots cron, the command (in solairs, not in front of a linux box at the mo) is  /usr/lib/newsyslog, so it should be something similar.
Stopping and restarting syslogd should start it off again
0
 

Author Comment

by:mcwalters
ID: 11996879
Ok, tried:

service syslogd restart

but it doesn't recognise the service?
0
 

Author Comment

by:mcwalters
ID: 11996928
Got it working now - it was

service syslog restart

Thanks
0
 
LVL 5

Expert Comment

by:paranoidcookie
ID: 12006433
If you are worried about logsize try using a program like logrotate which cna be made to archive and compress log files automatically for you.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question