Zum Inhalt springen

Cronjob Logeinträge im Syslog deaktivieren: Unterschied zwischen den Versionen

Aus LHlab Wiki
KKeine Bearbeitungszusammenfassung
KKeine Bearbeitungszusammenfassung
Zeile 9: Zeile 9:
#*.*;auth,authpriv.none        -/var/log/syslog
#*.*;auth,authpriv.none        -/var/log/syslog
*.*;cron,auth,authpriv.none    -/var/log/syslog
*.*;cron,auth,authpriv.none    -/var/log/syslog
</pre>einfach die bereits vorhandene Zeile aus kommentieren und die untenstehende einfügen.
</pre>einfach die bereits vorhandene Zeile aus kommentieren und die untenstehende einfügen.


Zeile 21: Zeile 20:
<code>/etc/rsyslog.d/01-blocklist.conf</code><syntaxhighlight lang="bash">
<code>/etc/rsyslog.d/01-blocklist.conf</code><syntaxhighlight lang="bash">
# Cronjob-Spam umleiten
# Cronjob-Spam umleiten
if $msg, contains, "pam_unix(cron:session):" then {
if $msg contains "pam_unix(cron:session):" then {
     stop
     stop
}
}

Version vom 31. Dezember 2020, 08:20 Uhr

Ein cronjob schreibt immer einen Logeintrag ins Syslog wenn dieser gelaufen ist. Um dies zu unterbinden, kann man einfach in der rsyslog Konfigurationsdatei den cron Daemon ausschließen und so die cron Loggings deaktivieren:

Beispiele eines cronjob Loggings:

  • CRON[18389]: (root) CMD (test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ))
  • CRON[18386]: (root) CMD (   /usr/local/sbin/digitalstrom_binding_tools.sh refresh > /dev/null)

/etc/rsyslog.conf

#*.*;auth,authpriv.none         -/var/log/syslog
*.*;cron,auth,authpriv.none     -/var/log/syslog

einfach die bereits vorhandene Zeile aus kommentieren und die untenstehende einfügen.

Es landen noch folgende Dinge im auth.log:

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

Um diese loszuwerden kann einfach eine Regel in der 01-blocklist.conf eingerichtet werden:

/etc/rsyslog.d/01-blocklist.conf

# Cronjob-Spam umleiten
if $msg contains "pam_unix(cron:session):" then {
    stop
}

zum Schluss starten wir den rsyslog neu:

systemctl restart rsyslog.service