- 查看当前占用前十内存进程
[yingjian@iZj6caursf93tp5g8692dyZ 20190215172108590907433256076310]$ ps aux | grep -v PID | sort -rn -k +4 | head
root 23111 0.2 22.6 4955428 3678744 ? Ssl 2021 1612:26 ./redis-server 127.0.0.1:6379
root 23295 0.1 15.3 3282496 2500224 ? Ssl 2021 328:24 /usr/sbin/rsyslogd -n
nginx 18372 0.0 0.8 366924 130380 ? S Apr19 0:14 php-fpm: pool www
nginx 9320 0.0 0.7 365896 129096 ? S Apr20 0:12 php-fpm: pool www
nginx 28751 0.0 0.7 364092 126904 ? S Apr22 0:04 php-fpm: pool www
nginx 27785 0.0 0.7 363844 127312 ? S Apr19 0:15 php-fpm: pool www
nginx 18434 0.0 0.7 363308 126532 ? S Apr19 0:14 php-fpm: pool www
nginx 13663 0.0 0.7 363316 126856 ? S Apr19 0:14 php-fpm: pool www
nginx 13293 0.0 0.7 363312 126808 ? S Apr19 0:13 php-fpm: pool www
nginx 12811 0.0 0.7 359964 123352 ? S Apr22 0:06 php-fpm: pool www
- 手动释放rsyslog内存
sudo systemctl restart rsyslog
3. 计划任务定时检测
脚本地址
[root@iZj6caursf93tp5g8692dyZ scripts]# cat check_rsys_log.sh
#!/usr/bin/bash
#Tate:2022.4.24
#Author:Yingjian
#function: 定时检测rsyslog服务内存使用
#env
local_time=`date`
mem_size=`ps -aux |grep -v grep |grep rsyslog |awk '{print $6}'`
if [ $mem_size -gt "500000" ];then
echo "$local_time 当前内存使用$mem_size" >> /data/scripts/check_rsyslog.log
systemctl restart rsyslog
else
echo "$local_time 当前内存使用$mem_size" >> /data/scripts/check_rsyslog.log
fi
添加到crontab
crontab -e
0 1 * * 1 /usr/bin/bash /data/scripts/check_rsys_log.sh #每周一 凌晨1点0分执行该脚本检测
本文参考:https://blog.csdn.net/lswzw/article/details/118331951