Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to empty log file

Posted on 2004-09-07
4
Medium Priority
?
583 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
  • 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

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
I have written articles previously comparing SARDU and YUMI.  I also included a couple of lines about Easy2boot (easy2boot.com).  I have now been using, and enjoying easy2boot as my sole multiboot utility for some years and realize that it deserves …
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.:
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month12 days, 14 hours left to enroll

971 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