How to empty log file

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.
mcwaltersAsked:
Who is Participating?
 
liddlerConnect With a Mentor Commented:
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
 
mcwaltersAuthor Commented:
Ok, tried:

service syslogd restart

but it doesn't recognise the service?
0
 
mcwaltersAuthor Commented:
Got it working now - it was

service syslog restart

Thanks
0
 
paranoidcookieCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.