情况描述
日志类似
Wed Feb 16 05:00:03 2022 cron.err crond[31109]: crond (busybox 1.33.2) started, log level 5
Wed Feb 16 05:00:18 2022 cron.err crond[1475]: crond (busybox 1.33.2) started, log level 5
分析结果
The FEATURE_SYSLOG_INFO 20 option appeared in BusyBox v. 1.31.0.
But in OpenWRT in order to save memory :slight_smile: this option is disabled by default: master 4, openwrt-21.02 branch 16.
As a result, BusyBox components (including cron) in syslog write all messages with the error level.
说人话,这就是普通的输出日志
OpenWRT默认crond的日志全部使用cron.err输出了
解决方法
鉴于日志详细信息并没说什么错误,可以当做crond正常运行的日志提示
或者
你不想它显示,把OpenWrt的系统日志等级调高
uci set system.@system[0].cronloglevel=9
uci commit
service cron restart
补充知识
cron 日志等级
OpenWrt Wiki
System configuration /etc/config/system
0 会打印所有信息
8 会打印命令执行
9或更高 只会记录错误日志
参考链接
Cron.err - why?
crond log level meaning
❌这个不适用于OpenWrtcrond log level
-l emerg or panic LOG_EMERG 0 [* system is unusable *]
-l alert LOG_ALERT 1 [* action must be taken immediately *]
-l crit LOG_CRIT 2 [* critical conditions *]
-l error or err LOG_ERR 3 [* error conditions *]
-l warn or warning LOG_WARNING 4 [* warning conditions *]
-l notice LOG_NOTICE 5 [* normal but significant condition *] the default
-l info LOG_INFO 6 [* informational *]
-l debug LOG_DEBUG 7 [* debug-level messages *] same as -d option
上文中的日志里可以看到log level使用的是5
我们如何更改它?
可以在crond的启动文件/etc/init.d/cron中看到端倪
...
start_service() {
procd_set_param command "$PROG" -f -c /etc/crontabs -l "${loglevel:-5}"
}
...
应该是这里的 5 修改为我们需要的等级即可
本文分析了OpenWRT系统中crond日志默认全部以cron.err级别输出的情况,指出由于内存节省原因, BusyBox的syslog_info20选项未启用。解决方案包括接受这些日志为正常运行的提示,或者通过调整系统设置(如将cron.loglevel设为9)来减少日志输出。此外,介绍了cron日志等级及其含义,并提供了修改crond启动文件以更改日志等级的方法。
1442

被折叠的 条评论
为什么被折叠?



