Link to home
Start Free TrialLog in
Avatar of mcwalters
mcwalters

asked on

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.
ASKER CERTIFIED SOLUTION
Avatar of liddler
liddler
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mcwalters
mcwalters

ASKER

Ok, tried:

service syslogd restart

but it doesn't recognise the service?
Got it working now - it was

service syslog restart

Thanks
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.