Solved

How to empty log file

Posted on 2004-09-07
4
567 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 50 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now