Linux
找不到 cron 配置文件
我有 CentOS 7 並試圖訪問一個看起來有點像這樣的配置文件:
# Cron configuration options # For quick reference, the currently available log levels are: # 0 no logging (errors are logged regardless) # 1 log start of jobs # 2 log end of jobs # 4 log jobs with exit status != 0 # 8 log the process identifier of child process (in all logs) #
我的目標是禁用 cron 日誌記錄。
我試過用Google搜尋,顯然有些人有類似的文件
/etc/default/cron
,/etc/rsyslog.d/50-Default.conf
但是當我搜尋它們時,這些文件都不存在。我確實有/etc/rsyslog.conf
並嘗試使用cron.none.* /var/log/messages
(我沒有/var/log/syslog
)禁用 cron 日誌記錄,但我仍然在我的遠端伺服器上獲取 cron 日誌。**如何停止 cron 日誌(但不是 cron 本身)?**我所做的一切似乎都無法阻止他們。
CentOS/RHEL 7 使用 cron 的cronie實現。您在那裡顯示的文件與vixie cron相關,用於 Debian 等發行版。
[root@centos7 ~]# head -2 /usr/share/doc/cron*/README 17. January 2008 mmaslano (at) redhat (dot) com Rename the fork on cronie. The source code could be found here: [root@centos7 ~]#
root@debian:/# head -20 /usr/share/doc/cron*/README #/* Copyright 1988,1990,1993 by Paul Vixie # * All rights reserved # * # * Distribute freely, except: don't remove my name from the source or # * documentation (don't take credit for my work), mark your changes (don't # * get me blamed for your possible bugs), don't alter or remove this # * notice. May be sold if buildable source is provided to buyer. No # * warrantee of any kind, express or implied, is included with this # * software; use at your own risk, responsibility for damages (if any) to # * anyone resulting from the use of this software rests entirely with the # * user. # * # * Send bug reports, bug fixes, enhancements, requests, flames, etc., and # * I'll try to keep a version up to date. I can be reached as follows: # * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul # */ Vixie Cron V3.0 December 27, 1993 [V2.2 was some time in 1992] root@debian:/#
預設情況下,cronie將
/var/log/cron
使用以下/etc/rsyslog.conf
條目發送所有 cron 消息[root@centos7 ~]# grep ^cron /etc/rsyslog.conf cron.* /var/log/cron [root@centos7 ~]#
要更改它們的寫入位置,請修改文件並重新啟動 rsyslog。無需重新啟動 cron。
[root@centos7 ~]# sed -i 's!/var/log/cron!/var/log/bob!' /etc/rsyslog.conf [root@centos7 ~]# grep ^cron /etc/rsyslog.conf cron.* /var/log/bob [root@centos7 ~]# systemctl restart rsyslog [root@centos7 ~]# tail /var/log/bob Jul 7 19:16:41 centos7 crontab[8581]: (root) LIST (root) Jul 7 19:17:01 centos7 CROND[8587]: (root) CMD (/bin/touch /tmp/foo) [root@centos7 ~]#
並由@doneal24 指出要完全丟棄條目,根據您的原始問題,您將使用
/etc/rsyslog.conf
如下行cron.* ~