英文:
How to Read Mongodb log number ubuntu
问题
在Ubuntu服务器上,我实施了logrotate以轮换日志文件,但我注意到一个问题,日志文件旁边的数字太大,我不理解如何读取日志旁边的数字“52548376”或它代表什么。
关于此问题是否有任何帮助,或者有关如何阅读它的解释?
以下是我的logrotate配置:
/var/log/mongodb/*.log {
rotate 7
daily
size 100M
missingok
create 0600 mongodb mongodb
delaycompress
compress
sharedscripts
postrotate
/bin/kill -SIGUSR1 $(pgrep -f mongod)
endscript
}
我注意到它应该在达到100MB后轮换日志。
英文:
So i have a log at ubuntu server that i implemented logrotate to rotate the log, but i notice one things that the number is too big and i dont understand how to read the number beside the log
Any help on this? or any explanation to how to read it "52548376" or what does it stand for
here is my configuration for logrotate:
/var/log/mongodb/*.log{
rotate 7
daily
size 100M
missingok
create 0600 mongodb mongodb
delaycompress
compress
sharedscripts
postrotate
/bin/kill -SIGUSR1 $(pgrep -f mongod)
endscript
}
i notice that it should rotate the log after it reached 100MB
答案1
得分: 1
这是字节大小。
52548376字节等于52兆字节,但您设置了100兆字节的限制,那么为什么您期望进行日志轮换呢?
我建议不要使用kill -SIGUSR1 $(pgrep -f mongod)
,而是使用
kill -SIGUSR1 $(/usr/sbin/pidof mongod)
或者更好的是
if /usr/sbin/pidof -s mongod > /dev/null ; then kill -USR1 $(/usr/sbin/pidof mongod) ; fi
您指定了daily
,这意味着日志文件每天都会轮换,无论大小是否达到100兆字节。只有在一天内运行logrotate
多次时,使用daily
和size
才有意义。
选项create
是不必要的。mongod
会自动创建新的日志文件。相反,我建议添加notifempty
。
英文:
That's the file size in Bytes.
52548376 Bytes are 52MByte but you set a limit of 100MByte, so why do you expect a log rotation?
Instead of kill -SIGUSR1 $(pgrep -f mongod)
I would suggest
kill -SIGUSR1 $( /usr/sbin/pidof mongod )
or even better
if /usr/sbin/pidof -s mongod > /dev/null ; then kill -USR1 $( /usr/sbin/pidof mongod ) ; fi
You specified daily
which means the logfile is rotated daily, no matter whether the size reached 100MB or not. Using daily
and size
makes only sense if you run logrotate
more than once a day.
Option create
is not needed. mongod creates a new logfile automatically. Instead I would add notifempty
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论