ein kleines Problem mit meinen Crontabs.
Und zwar ging ich bisher (um einen neuen Crontab anzulegen) via SFTP auf die Datei /etc/crontab und habe diese mit meinem Editor bearbeitet und gesichert. Das klappt soweit auch wunderbar (so arbeite ich fast nur an den Daten meines Servers). Klapp ja auch immer super!
Meine /etc/crontab sieht aktuell so aus:
Code: Alles auswählen
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=info@domain.de
#
# System
#
30 * * * * root run-parts /etc/cron.hourly
0 3 * * * root run-parts /etc/cron.daily
0 1 * * 1 root run-parts /etc/cron.weekly
0 5 1 * * root run-parts /etc/cron.monthly
#
# Plesk MailForwarder aktualisieren
#
*/2 * * * * root /var/vmail/PleskMailRedirect.pl &> /dev/null
#
# RSnapshot Backup System
#
45 4-23 * * * root rsnapshot hourly &> /dev/null
0 2 * * * root cp -R /_backup/hourly.0/* /store/backup/`date +\%Y-\%m-\%d` &> /dev/null
0 4 * * * root rm -Rf /store/backup/`date +\%Y-\%m-\%d '--date=5 days ago'` &> /dev/null
30 6 * * 1 root tar -cvzf /store/snapshot.tar.gz /store/backup/`date +\%Y-\%m-\%d` &> /dev/null
#
# MYSQL Backup
#
0 0 * * * root perl /var/www/vhosts/domain.de/subdomains/srv.mysqldumper/httpdocs/msd_cron/crondump.pl -config=mysqldumper -html_output=0 &> /dev/null
0 1 * * * root rm -R /_backup/mysql/* && cp -R /var/www/vhosts/domain.de/subdomains/srv.mysqldumper/httpdocs/work/backup/* /_backup/mysql
#
# Spamassassin Update
#
30 1 * * * root sa-update
Dann hab ich mir Gedanken dazu gemacht, dass ich es ja eigentlich wie alle anderen via "crontab -u root -e" eintragen kann, demnach mit Sicherheit auch ohne den User root anzugeben. Habe dann aber bemerkt, dass die "/etc/crontab" den gleichen Inhalt wie "crontab -u root -e" hat. Ist das normal? Hatte gestern auch ein "crontab /etc/crontab" ausgeführt als User root. Dann gleich er nach Änderungen beide Crontab Stellen miteinander ab.
Da ich die Cronjobs nun in "/etc/crontab" UND in "crontab -u root -e" stehen habe, habe ich irgendwie das Gefühl, dass diese komplett zwei mal ausgeführt werden?
Wie soll ich es am besten machen?
Die "# System" in der /etc/crontab lassen, alle anderen ohne Userangabe in "crontab -u root -e"?
Ich wette, die Cronjobs sind nun alle zwei mal drin, richtig?
Ich weiß, es gibt schon Haufenweise Themen dazu, aber kann damit kaum etwas anfangen, da bei mir die Fehlermeldungen erst kommen, seitdem die oben genannte Zeile drin ist.
Grüße und Danke!
caom
Edit:
habe es mit einem E-Mail Versand aus den beiden crontabs heraus feststellen können: Es werden wie vermutet zwei mal die Cronjobs gleichzeitig abgefeuert.
Habe es nun also so gemacht:
crontab -u root -e:
Code: Alles auswählen
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=info@domain.de
#
# Plesk MailForwarder aktualisieren
#
*/2 * * * * /var/vmail/PleskMailRedirect.pl &> /dev/null
#
# RSnapshot Backup System
#
45 4-23 * * * rsnapshot hourly &> /dev/null
0 2 * * * cp -R /_backup/hourly.0/* /store/backup/`date +\%Y-\%m-\%d` &> /dev/null
0 4 * * * rm -Rf /store/backup/`date +\%Y-\%m-\%d '--date=5 days ago'` &> /dev/null
30 6 * * 1 tar -cvzf /store/snapshot.tar.gz /store/backup/`date +\%Y-\%m-\%d` &> /dev/null
#
# MYSQL Backup
#
0 0 * * * perl /var/www/vhosts/domain.de/subdomains/srv.mysqldumper/httpdocs/msd_cron/crondump.pl -config=mysqldumper -html_output=0 &> /dev/null
0 1 * * * rm -R /_backup/mysql/* && cp -R /var/www/vhosts/domain.de/subdomains/srv.mysqldumper/httpdocs/work/backup/* /_backup/mysql
#
# Spamassassin Update
#
30 1 * * * sa-update
Code: Alles auswählen
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=info@domain.de
#
# System
#
30 * * * * root run-parts /etc/cron.hourly
0 3 * * * root run-parts /etc/cron.daily
0 1 * * 1 root run-parts /etc/cron.weekly
0 5 1 * * root run-parts /etc/cron.monthly
Das einzige was mich nur verwirrt ist, wenn ich z.B.
Code: Alles auswählen
#
# Plesk MailForwarder aktualisieren
#
*/2 * * * * root /var/vmail/PleskMailRedirect.pl &> /dev/null
Warum ist das so?