cronjob

Nancy L Henderson

Angesehenes Mitglied
hallo, ich habe mich noch nicht weiter mit dem Thema Cronjobs auseinander gesetzt.
Wollte allerdings mal kurz was fragen:

Bei Debian gibt es bekanntlich Ordner wie: /etc/cron.daily, /etc/cron.hourly usw.
Jetzt hab ich schon ein Script zur täglichen Datensicherung in /etc/cron.daily gelegt das wird auch jeden Tag um 0 Uhr igendwas aufgerufen und macht die Sicherung.

Jetzt will ich das ein Script jede Stunde ausgeführt wird. Also habe ich mir gedacht wo es den Ordner /etc/cron.hourly ja schon gibt, leg ich mein Script also da rein. Gesagt getan doch es wird nicht aufgerufen...

Ich habe das Script als User root getestet, ihm Chmod a+x gegeben usw. Es kann also nicht an einem Fehler im Script liegen sondern irgendwie will der CronDienst den Ordner nicht. Wie kann ich ihn dazu bringen das zu tun was ich will: Mein Script ausführen.

Und ja ich weiss das man mit crontab -e seine eigenen Crons schreiben kann. Ich hätte es aber gern in diesem Ordner... wenn es den doch schon gibt ?!
wink.gif
 
Ciao,
Ich kenne die Debian-Implementierung nicht, habe aber 20 Jahre UNIX auf dem Buckel.
Früher hätte man gesagt RFM oder RTFM, heute rate ich dir "man cron" oder "man crontab".

Habe schnell auf meinem Roten Hut nachgeschaut:

QUOTE EXAMPLE CRON FILE
# use /bin/sh to run commands, overriding the default set by cron
SHELL=/bin/sh
# mail any output to `paul', no matter whose crontab this is
MAILTO=paul
#
# run five minutes after midnight, every day
5 0 * * * $HOME/bin/daily.job >> $HOME/tmp/out 2>&1
# run at 2:15pm on the first of every month -- output mailed to paul
15 14 1 * * $HOME/bin/monthly
# run at 10 pm on weekdays, annoy Joe
0 22 * * 1-5 mail -s "It's 10pm" joe%Joe,%%Where are your kids?%
23 0-23/2 * * * echo "run 23 minutes after midn, 2am, 4am ..., everyday"
5 4 * * sun echo "run at 5 after 4 every sunday"



Da du hier in einer RTM Zone bist, ohne das F!


QUOTE The format of a cron command is very much the V7 standard, with a number
of upward-compatible extensions. Each line has five time and date
fields, followed by a user name (with optional ``:<group>'' and
``/<login-class>'' suffixes) if this is the system crontab file, followed
by a command. Commands are executed by cron(8) when the minute, hour,
and month of year fields match the current time, and when at least one of
the two day fields (day of month, or day of week) match the current time
(see ``Note'' below). cron(8) examines cron entries once every minute.
The time and date fields are:

field allowed values
----- --------------
minute 0-59
hour 0-23
day of month 1-31
month 1-12 (or names, see below)
day of week 0-7 (0 or 7 is Sun, or use names)

A field may be an asterisk (*), which always stands for ``first-last''.



Alles klar?

Mit besten Grüssen
Boubou7
 
Hallo

Vielleicht fehlt der Eintrag für cron.hourly im /etc/crontab ? War / Ist bei unserem alten Debian Server auch so.

Gruss
Roger
 
juhu ihr seit die besten. Danke!

In /etc/crontab

stand zwar schon etwas drin mit hourly aber der Eintrag war meiner Meinung nach komisch. Also habe ich den Eintrag für /etc/cron.daily kopiert und entsprechend für hourly angepasst. Dann hab ich den Befehl für /etc/cron.hourly mal ausgeführt und er hat bei meinem Script gemeckert ... ein Formatfehler. Ich hab mal in die erste Zeile meines Scripts folgendes eingefügt dann gings:

#!/bin/sh

Meine komplette funktionierende Crontab Datei (nur fals mal jemand ein änliches Problem hat):

CODE
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file.
# This file also has a username field, that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user command
59 * * * * root test -x /usr/sbin/anacron || run-parts --report /etc/cron.hourly
4 1 * * * root test -x /usr/sbin/anacron || run-parts --report /etc/cron.daily
25 3 * * 7 root test -x /usr/sbin/anacron || run-parts --report /etc/cron.weekly
0 4 12 * * root test -x /usr/sbin/anacron || run-parts --report /etc/cron.monthly
#



Nochmals viele danke!
 
Zurück
Oben