Centos – How to delete old log files

bashcentos

I'm trying to figure out how can I delete old log files, I'm using Centos 6.5 and in my /var/log I see these old log files

messages
messages-20150802
messages-20150802

also the same in the /var/log/httpd directory

access_log
access_log-20150802
access_log-20150809
access_log-20150816
access_log-20150823

I need to delete the older files that end with numeric values but keep the main once. what command could I use to do this.

Thanks in advanced

Best Answer

You can just use this commands:

rm -f messages-*
rm -f access_log-*

It will delete all old logs which starts with "messages-" and "access_log-"