linux 日志 停止滚动,linux – syslog在日志轮换后停止记录
发布日期:2021-06-24 12:27:33 浏览次数:2 分类:技术文章

本文共 1260 字,大约阅读时间需要 4 分钟。

每次newsyslog旋转日志文件后,syslog都会停止登录该文件.直到syslogd重启完成.

(myserver:wheel)# logger -p local1.info -t myprocess "hello thiru"; ll myfile.log; cat myfile.log

-rw-r--r-- 1 root wheel 0B Nov 10 11:26 myfile.log

(myserver:wheel)# /etc/rc.d/syslogd restart

Stopping syslogd.

Starting syslogd.

(myserver:wheel)# logger -p local1.info -t myprocess "hello thiru"; ll myfile.log; cat myfile.log

-rw-r--r-- 1 root wheel 44B Nov 10 12:04 myfile.log

Nov 10 12:04:31 myserver myprocess: hello thiru

(myserver:wheel)#

在Linux(使用logrotate)上,我们可以通过在logroate conf的postrotate部分中执行syslog / rsyslog重新启动来解决此问题.

在newsyslog中有类似于postrotate的东西吗?

编辑:

Syslog和newsyslog conf文件:

(TPC-E11-36:wheel)# cat /etc/newsyslog.d/newsyslog-myprocess.conf

/var/log/myfile.log 644 20 10000 * Z

(TPC-E11-36:wheel)# cat /etc/syslog.d/syslog-myprocess.conf

!myprocess

local1.info /var/log/myfile.log

(TPC-E11-36:wheel)#

解决方法:

将pidfile的路径添加到/etc/newsyslog.conf中,如果需要,还有一个代表SIGHUP的信号,有关newsyslog的更多信息:https://www.freebsd.org/doc/handbook/configtuning-syslog.html

格式/示例是这样的:

# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]

/var/log/your-app.log root:wheel 600 7 * @T00 GBJC /var/run/your-app.pid 1

标签:linux,syslog,freebsd,logrotate,logging

来源: https://codeday.me/bug/20190706/1393333.html

转载地址:https://blog.csdn.net/weixin_32697149/article/details/116821740 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:linux测试网页装载时间,如何用Flood测试Web服务器响应时间
下一篇:linux能安装音乐软件吗,Linux上如何安装使用音乐软件SoundCloud

发表评论

最新留言

不错!
[***.144.177.141]2024年04月20日 07时44分03秒