当前位置:首页 - Linux

linux 清理删除远程登录日志

作者:高景洋 日期:2023-07-17 21:23:13 浏览次数:395

我们在实际的linux远程连接过程中,会产生很多垃圾日志,如何清理这些登录日志呢?


1、将以下脚本存成 cl.sh 文件,上传到服务器上


#!/usr/bin/bash


echo > /var/log/syslog
echo > /var/log/messages
echo > /var/log/xferlog
echo > /var/log/secure
echo > /var/log/auth.log
echo > /var/log/user.log
echo > /var/log/wtmp
echo > /var/log/lastlog
echo > /var/log/btmp
echo > /var/run/utmp

history -c



2、在服务器上,执行 source cl.sh ,即可清理日志

本文永久性链接:
<a href="http://r4.com.cn/art236.aspx">linux 清理删除远程登录日志</a>
当前header:Host: r4.com.cn X-Host1: r4.com.cn X-Host2: r4.com.cn X-Host3: 127.0.0.1:8080 X-Forwarded-For: 44.197.231.211 X-Real-Ip: 44.197.231.211 X-Domain: r4.com.cn X-Request: GET /art236.aspx HTTP/1.1 X-Request-Uri: /art236.aspx Connection: close User-Agent: CCBot/2.0 (https://commoncrawl.org/faq/) Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-US,en;q=0.5 If-Modified-Since: Mon, 02 Oct 2023 08:23:43 GMT Accept-Encoding: br,gzip