[gelöst]Cron-Logs in eigene Datei schreiben

Alle weiteren Dienste, die nicht in die drei oberen Foren gehören.
Antworten
frankieboy
Beiträge: 355
Registriert: 19.08.2003 15:25:48
Wohnort: Bremen

[gelöst]Cron-Logs in eigene Datei schreiben

Beitrag von frankieboy » 09.07.2013 11:25:49

Hallo Forum,

eingerichte Cron-Jobs funktionieren einwandfrei, was schon mal sehr gut ist. Die Ausführung wird aktuell noch in /var/log/syslog dokumentiert. Jetzt möchte ich, dass die Dokumentation in /var/log/cron.log erfolgt. Leider habe ich das nur auf meinem "Home-Server" (Testing) hinbekomme, nicht jedoch auf dem ""Online-Produktiv-Server" (Stable).

Die entscheidende(?) Passage der Config-Datei "/etc/rsyslog" sieht so aus:

Code: Alles auswählen

# To enable high precision timestamps, comment out the following line.
#
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat

#
# Set the default permissions for all log files.
#
$FileOwner root
$FileGroup adm
$FileCreateMode 0640
$DirCreateMode 0755
$Umask 0022

#
# Where to place spool and state files
#
$WorkDirectory /var/spool/rsyslog

#
# Include all config files in /etc/rsyslog.d/
#
$IncludeConfig /etc/rsyslog.d/*.conf


###############
#### RULES ####
###############

#
# First some standard log files.  Log by facility.
#
auth,authpriv.*                 /var/log/auth.log
*.*;auth,authpriv.none          -/var/log/syslog
cron.*                          -/var/log/cron.log
daemon.*                        -/var/log/daemon.log
kern.*                          -/var/log/kern.log
lpr.*                           -/var/log/lpr.log
mail.*                          -/var/log/mail.log
user.*                          -/var/log/user.log
Das Verzeichnis "/etc/rsyslog.d" ist übrigens leer.

Was kann bzw. sollte ich noch tun?
Zuletzt geändert von frankieboy am 10.07.2013 10:43:39, insgesamt 1-mal geändert.
Debian Bookworm mit xfce-Desktop

frankieboy
Beiträge: 355
Registriert: 19.08.2003 15:25:48
Wohnort: Bremen

Fehlerhinweis(?) und neuer Fehler(?)

Beitrag von frankieboy » 09.07.2013 13:12:03

Hallo,

Wie ich im Rahmen der Fehlersuche jetzt festgestellt habe, wird die mit "crontab -e" erstellten/bearbeiteten Crons in "var/spool/cron/contabs/root" gespeichert.

Code: Alles auswählen

[# Standard-Cron-Kommentar-Hinweis#]
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command

*/5 * * * *     touch /var/www/crontest
Außerdem gibt es noch die Datei "/etc/crontabs"

Code: Alles auswählen

[# Standard-Cron-Kommentar-Hinweis#]
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user	command
17 *	* * *	root    cd / && run-parts --report /etc/cron.hourly
25 6	* * *	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6	* * 7	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6	1 * *	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
Ist das eigentlich "normal"?
Debian Bookworm mit xfce-Desktop

Cae
Beiträge: 6349
Registriert: 17.07.2011 23:36:39
Wohnort: 2130706433

Re: Cron-Logs in eigene Datei schreiben

Beitrag von Cae » 09.07.2013 15:48:31

Ja. Jeder User hat 'ne eigene Crontab in /var/spool/cron, fuer global gibt's die crontab und einzelne Dateien in /etc/cron.d/. Ausserdem gibt's noch /etc/cron.{hourly,daily,weekly,mounthly}.d/ nach demselben Prinzip.

Eigentlich stimmt das, was du da tust, siehe cron(8):

Code: Alles auswählen

       cron logs its action to the syslog facility 'cron', and logging may  be
       controlled using the standard syslogd(8) facility.
rsyslogd ist restartet worden? reload macht neuerdings imho nur noch alle Logs auf und zu, laedt aber keine Aenderungen aus der Config.

Gruss Cae
If universal surveillance were the answer, lots of us would have moved to the former East Germany. If surveillance cameras were the answer, camera-happy London, with something like 500,000 of them at a cost of $700 million, would be the safest city on the planet.

—Bruce Schneier

frankieboy
Beiträge: 355
Registriert: 19.08.2003 15:25:48
Wohnort: Bremen

Re: Cron-Logs in eigene Datei schreiben

Beitrag von frankieboy » 10.07.2013 10:43:04

Cae hat geschrieben:rsyslogd ist restartet worden?
Das war der entscheidendende Hinweis. Vielen Dank.

Nach einem ...

Code: Alles auswählen

service rsyslog restart
... werden die Log-Dateien wie gewünscht erstellt. Nochmal Danke.
Debian Bookworm mit xfce-Desktop

Antworten