Cron-Job wird nach ordnungsgemäßer Einrichtung nicht ausgeführt

Cron-Job wird nach ordnungsgemäßer Einrichtung nicht ausgeführt

Also habe ich einen Cron-Job wie unten gezeigt erstellt:

  GNU nano 2.2.6                    File: /tmp/crontab.uNoEXy/crontab

# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
*/3 *  *    *   *    /home/kyle/runBackup.sh

Das führt das Skript für einen Test alle drei Minuten wie angegeben aus. Ja, überprüfen Sie, var/log/syslogob für heute kein Cron-Lauf geplant ist. Ein Beweis dafür, dass dieser Cron ausgeführt wird, ist eine .tar.gzDatei in meinem Dropbox-Ordner – was passiert, wenn Sie das Skript selbst ausführen. Wenn Sie es nur in einen Cron einfügen, passiert nichts.

Antwort1

Versuche es mit:

*/3 * * * * /home/kyle/runBackup.sh

Ein CRON-Ausdruck ist eine Zeichenfolge aus fünf odersechs durch Leerzeichen getrennte Felder

Einzelheiten finden Sie unter:http://en.wikipedia.org/wiki/Cron

Antwort2

Ich hatte ein sehr ähnliches Problem und bemerkte, dass nach der geplanten Ausführung des Jobs E-Mails für Root in /var/spool/mail abgelegt wurden. Der Job wurde in der Root-Crontab abgelegt, was darauf hindeutete, dass der Root-Benutzer keine Berechtigung zum Ausführen des Jobs hatte. Ich habe mich ein wenig umgesehen und es stellte sich heraus, dass es daran lag, dass das Zielskript nicht ausführbar war. Wenn Sie das tun:

ls -la /home/kyle/

und runBackup.sh zeigt die Berechtigungen -rw-r--r-- an. Versuchen Sie dann:

chmod +x /home/kyle/runBackup.sh

Dadurch sollten die Berechtigungen -rwxr-xr-x festgelegt werden und die Ausführung des Jobs ermöglicht werden.

Quellenmaterial

verwandte Informationen