在网上找了一些清空系统日志的语句,也可以把他们制作成脚本,更加方便一些:
#!/bin/sh
cat /dev/null>/var/log/syslog
cat /dev/null>/var/adm/sylog
cat /dev/null>/var/log/wtmp
cat /dev/null>/var/log/maillog
cat /dev/null>/var/log/messages
cat /dev/null>/var/log/openwebmail.log
cat /dev/null>/var/log/maillog
cat /dev/null>/var/log/secure
cat /dev/null>/var/log/httpd/error_log
cat /dev/null>/var/log/httpd/ssl_error_log
cat /dev/null>/var/log/httpd/ssl_request_log
cat /dev/null>/var/log/httpd/ssl_access_log
注意清空之后要记得重启服务,否则日志将不会继续打下去。
使用命令(CentOS 和红帽):
service rsyslog start
service sshd restart
本文提供了一种清空Linux系统日志的方法,通过shell脚本实现一键清空多个日志文件,并提醒用户清空后需重启服务以确保日志记录正常进行。
1080

被折叠的 条评论
为什么被折叠?



