auth.log 频繁出现Cron: pam_unix (cron:session): session opened/closed for user root by (uid=0)

This is my week of playing around with mail servers and I have been keeping an eye on the logs on a regular basis. I noticed that the auth.logwas riddled with millions of these pointless (from my POV anyhow) log entries:

CRON: pam_unix(cron:session): session opened for user root by (uid=0)
CRON: pam_unix(cron:session): session closed for user root

This is - as is readily apparent - happening because of cron which can run every minute, every 10 minutes, every hour, and so on as configured. When cron does this running it often runs as root and doing so creates a session for said user. This, due to the default settings of most Linices, is logged (which does seem prudent if it wasn't so annoying) in auth.log. A kind soul on the Debian bug tracker has provided a solution that does not log this session activity, but only when run by cron. To do this (on Debian/Ubuntu):

修改步骤:

  • Go to the /etc/pam.d directory.
  • Open the file common-session-noninteractive in an editor.
  • Look for the following line:
    session required        pam_unix.so
  • Above this line, add the following:
    session     [success=1 default=ignore] pam_succeed_if.so service in cron quiet use_uid
  • Save the file and exit.
  • Restart crond using something like service cron restart.

... and that should do it!

Hope this helps :)

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值