Linux下定期清空被正在运行服务占用的日志文件

linux下定期删除日志:

运用linux下的while true循环,加上echo "" > ***.log 完成

while :; do
#echo "" > nohup.out
# ls "dir" -lR |grep -v ^d|awk '{print $9}' |tr -s '\n' > ./list.txt
# echo "text"|  tee $(find $(pwd) -name "*.out")  > /dev/null
# echo "text"|  tee -a $(cat ./list.txt)  > /dev/null
echo $(date +%F%n%T)|  tee $(find $(pwd) -name "*.out")  > /dev/null # 输入内容替换为“”
# find $(pwd) -name "*.out"
echo $(date +%F%n%T)
echo "log clear end"
sleep 5s
done
posted @   Iron__Man  阅读(261)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 什么是nginx的强缓存和协商缓存
· 一文读懂知识蒸馏
· Manus爆火,是硬核还是营销?
点击右上角即可分享
微信分享提示