
Mein Server ist CentOS 5. Wenn ich /etc/crontab bearbeite oder eine beliebige Benutzer-Crontab (einschließlich Root) über den Befehl „crontab -e“ bearbeite, wird einfach „(System) RELOAD (/etc/crontab)" oder "(admin) RELOAD (cron/admin)" im Protokoll. Kein CMD im /var/log/cron.
Beispieleintrag in /var/log/cron:
Aug 10 10:21:33 localhost crontab[31688]: (root) BEGIN EDIT (root)
Aug 10 10:21:42 localhost crontab[31688]: (root) REPLACE (root)
Aug 10 10:21:42 localhost crontab[31688]: (root) END EDIT (root)
Aug 10 10:22:01 localhost crond[2688]: (root) RELOAD (cron/root)
Ergebnis von „Service-Crond-Status“:
crond (pid 1345) is running...
Der Befehl "cat /var/log/messages | grep cron" liefert nichts.
Inhalt von /etc/cron.allow:
admin
root
Inhalt von /etc/crontab:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
* * * * * root run-parts /bin/date >> /data/date.txt
Ergebnis von ps aux |grep cron:
root 1345 0.0 0.1 5268 1204 ? Ss 11:43 0:00 crond
Inhalt der Crontab des Administrators:
* * * * * /bin/date >> /data/date.txt
Beachten Sie, dass nicht nur die Crontab des Administrators nicht ausgeführt wird. Alle Cron-Jobs werden nicht ausgeführt.
Irgendwelche Ideen, warum sie nicht laufen?
Antwort1
Überprüfen Sie, dass Sie keine Datei /etc/cron.allow oder /etc/cron.deny haben, die dazu führt, dass Jobs ignoriert werden.
Wenn /etc/cron.allow nicht vorhanden ist, kann jeder Cron-Jobs ausführen. Wenn es vorhanden, aber leer ist, bin ich nicht sicher, ob das jedem erlaubt, Cron-Jobs auszuführen.
Antwort2
Es liegt ein Fehler in Ihrer Crontab vor. Sehen Sie sich Folgendes an:
* * * * * root run-parts /bin/date >> /data/date.txt
Sie rufen run-parts mit dem Verzeichnis /bin/date auf - das wird sicherlich fehlschlagen. Der Fehler geht an stderr und wird nicht zwischengespeichert von>>
Antwort3
Erstellen Sie die Datei mit dem Namen, /etc/cron.allow
falls sie noch nicht vorhanden ist, und fügen Sie ihr den Benutzernamen hinzu.
Antwort4
Obwohl die Antwort auf diese Frage akzeptiert wurde, möchte ich hinzufügen, was bei mir funktioniert hat. Es ist eine gute Idee, die URL in Anführungszeichen zu setzen. Wenn sie eine Abfrage enthält, funktioniert sie möglicherweise nicht, ohne dass alles in Anführungszeichen gesetzt wird.
VERGESSEN SIE NICHT, IHRE URL, DIE "?, =, #, %" ENTHÄLT, IN ANFÜHRUNGSZITATE ZU SETZEN.
Beispiel. https://paystack.com/indexphp?docs/api/#transaction-charge-authorization&date=today sollte in einem Zitat stehen, etwa so: „https://paystack.com/indexphp?docs/api/#transaction-charge-authorization&date=today“