viernes, 13 de diciembre de 2013

Como borrar los logs en Linux or Unix

Delete a log files in Linux or UNIX

by on February 2, 2007 · 10 comments· LAST UPDATED February 2, 2007
Q. How do I delete a log file in Linux without distributing running application? My log file size is quite huge.
A. You can simply truncate a log file using > filename syntax. For example if log file name is /var/log/message, use:
# >/var/log/message
If you really wanted to delete or remove a file type:
# rm /var/log/message


logrotate tool

A better approach is to use logrotate tool. It is designed to ease administration of systems that generate large numbers of log files. It allows automatic rotation, compression, removal, and mailing of log files. Each log file may be handled daily, weekly, monthly, or when it grows too large.

See previous logrotate faq article

-----------------------------------------------------
crontab -e

luego copiar el siguiente contenido este limpiara estos archivos logs cada  30 minutos

*/30 * * * * >/var/log/syslog
*/30 * * * * >/var/log/kern.log

No hay comentarios:

Publicar un comentario