Linux   发布时间:2019-10-31  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了crontab清理日志大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

1.日志介绍

title="crontab清理日志" alt="crontab清理日志" src="https://cn.js-code.com/res/2019/01-12/17/f85f5e70dde565b90a7410c94c1cba97.png" width="540" height="190">

2.日志清理 (以下达到清理效果)

du -sh * //查看日志大小

title="crontab清理日志" alt="crontab清理日志" src="https://cn.js-code.com/res/2019/01-12/17/7ff06d37af3ee1ccd5efdfdaad6fe79a.png" width="421" height="305">

title="crontab清理日志" alt="crontab清理日志" src="https://cn.js-code.com/res/2019/01-12/17/fbb18131b69501eb66513c93d1b3c976.png" width="469" height="31">

/var/log/message

解释/dev/null 代表是一个黑洞文件,也就是一个空文件

cat /dev/null 使用cat输出一个空,将这个空重定向到/var/log/message,实现将message文件清空操作

title="crontab清理日志" alt="crontab清理日志" src="https://cn.js-code.com/res/2019/01-12/17/ffe0534a9f0c54caef699ed9e918318d.png" width="192" height="212">

3.编写sh文件(> 重定向)

在root目录下新建sh文件 vim /root/clean_log.sh

title="crontab清理日志" alt="crontab清理日志" src="https://cn.js-code.com/res/2019/01-12/17/8a0c62c054c57a981faae7e90a03fb57.png" width="416" height="223">

重启使任务生效

title="crontab清理日志" alt="crontab清理日志" src="https://cn.js-code.com/res/2019/01-12/17/5e3cfdb9d32b3f18e791ced31a1e16ae.png" width="411" height="60">

大佬总结

以上是大佬教程为你收集整理的crontab清理日志全部内容,希望文章能够帮你解决crontab清理日志所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: