Delete a log files in Linux or UNIX
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