PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Debian 8 cronjob startet nicht



PinguinPanic
06.11.15, 14:19
Hallo. Installiert habe ich Debian 8 (64 bit) Xfce.
Ich möchte einen cronjob einrichten aber das funktioniert nicht.
Was ich bis jetzt gemacht habe ich habe ein Script >>>

#!/bin/bash
cp -u -r /media/y/baxxx-4414-4743-bce3-3c0609exxxxxx/home/i/Schreibtisch/bash.sh

Wenn ich meinen cronjob per crontab -e einrichte

errors in crontab file, can't install.
Mein cronjob ist so aufgebaut

# 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)
1 ***** /media/y/baxxx-4414-4743-bce3-3c0609exxxxxx/home/i/Schreibtisch/home/y/Schreibtisch//bash.sh
#
# m h dom mon dow command

Wer kann mir weiterhelfen und den Fehler ausmerzen damit Debian 8 den cronjob erfolgreich ausführt?

DrunkenFreak
06.11.15, 14:44
Es fehlen Leerzeichen in der Zeile und es sind zu viele Sternchen.

PinguinPanic
06.11.15, 15:45
Jetzt habe ich den cronjob nochmal angepasst.

# 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)
#
1 * * * * /home/y/cron.sh > /home/y/Schreibtisch/cronjobgestratet.txt 2>&1
#
#
# m h dom mon dow command
Aber funktionieren tut es immer noch nicht.

PinguinPanic
06.11.15, 15:48
Auch nach einem

1 * * * * /home/y/cron.sh > /home/y/Schreibtisch/cronjobgestratet.txt
funktioniert es nicht.

PinguinPanic
06.11.15, 16:09
cronjobgestratet.txt, aber ohne inhalt.
ist erstellt worden, damit ist der cronjob wohl gestartet.
cron.sh

#!/bin/bash
cp -u -r /media/y/ba065390-4414-4743-bce3-3c0609ec68ca/home/internet/Schreibtisch /home/y/Schreibtisch/

wurde nicht abgearbeitet.
Damit ist das hiesige Thema noch nicht gelöst.

marce
06.11.15, 16:47
Welche Rechte hat denn Dein Script?

... und evtl. würde es sich lohnen, auch die Fehlerausgabe des CronJobs umzuleiten.

PinguinPanic
06.11.15, 16:54
Ich hatte das Script für jeden lesbar und schreibbar abgespeichert.
Wie leitet man die Fehlerausgabe eines cronjobs um?

marce
06.11.15, 17:01
... ist das Script denn auch ausführbar?

https://www.google.de/search?q=cronjob+fehler+ausgabe+umleiten

PinguinPanic
06.11.15, 17:07
Das Script ist ausführbar.

marce
06.11.15, 17:19
Sicher? Beweise?

PinguinPanic
06.11.15, 17:48
Hier hätte ich ein Bildschirmfoto >>>
http://img5.fotos-hochladen.net/uploads/bildschirmfoto9hp1tmkane.jpg
Aber der cronjob funktioniert immer noch nicht.

marce
06.11.15, 17:50
So, und jetzt bitte als Text in [code]-Tags aus der Konsole heraus.

PinguinPanic
06.11.15, 17:53
#!/bin/bash
cp -u -r /media/andy/ba065390-4414-4743-bce3-3c0609ec68ca/home/internet/Schreibtisch /home/andy/Schreibtisch/

marce
06.11.15, 17:55
die Rechte des Scriptes.

Also sowas wie
ls -la /Pfad/zur/Datei

BetterWorld
06.11.15, 19:44
Ich behaupte mal, der Job wurde ausgeführt.

Da cp seine Ausgabe auf STDERR macht, solltest du die Umleitung ungefähr so machen:
cp -u..... Quelldateien Zielverzeichnis 2>meinGenialCronJobLog.txt

PinguinPanic
07.11.15, 04:50
marce (http://www.linuxforen.de/forums/member.php?23254-marce)

ls -la /home/andy/cron.sh

-rwxrwxrwx 1 andy andy 122 Nov 6 11:10 /home/andy/cron.sh

PinguinPanic
07.11.15, 05:01
Dies ist der cronjob >>>

1 * * * * /home/andy/cron.sh > /home/andy/Schreibtisch/cronjobgestratet.txt >/home/andy/Schreibtisch/meinGenialCronJobLog.txt


Hat nicht funktioniert. Die Datei meinGenialCronJobLog.txt blieb leer.
Ich hatte länger als 1 Minute gewartet aber es tat sich nichts.

fork
07.11.15, 06:43
1 * * * * bla.sh


Das bedeutet nicht, dass das Script jede Minute ausgeführt sondern in Minute 1 jeder Stunde.



* * * * * bla.sh


So wird das Script jede Minute ausgeführt.

PinguinPanic
07.11.15, 08:44
Danke
fork (http://www.linuxforen.de/forums/member.php?6777-fork)

jetzt startet der cronjob 1 mal die Minute. Aber mein eigentliches Problem das der cronjob abläuft ist noch nicht gelöst.

PinguinPanic
07.11.15, 08:49
Ich hatte den cronjob geringfügig modifiziert >>>
* * * * * root /home/andy/cron.sh > /home/andy/Schreibtisch/cronjobgestratet.txt >/home/andy/Schreibtisch/meinGenialCronJobLog.txt
abergeholfen hat es nicht meinGenialCronJobLog.txt wurde erstellt und bleibt leer, damit ist bis jetzt der Kopiervorgang nicht erfolgt.
Wer weiss weiter?

PinguinPanic
07.11.15, 09:03
Das mounten der Partition
/media/andy/ba065390-4414-4743-bce3-3c0609ec68ca/
brachte keinen Erfolg.

Aqualung
07.11.15, 10:15
Lass die Umleitungen mal komplett weg, d.h. im cronjob steht nur noch:


* * * * * root /home/andy/cron.sh

Die Fehlermeldungen von cron landen AFAIK in der mailbox von root:

Lesen kannst Du sie, indem Du an der Konstole eingibst:



sudo -s
mail


Dann sollte eine Übersicht kommen ähnlich wie



mail
Heirloom mailx version 12.5 7/5/10. Type ? for help.
"/var/mail/root": 2 messages 2 new
>N 1 root@host Sat Oct 17 12:18 35/971 cronjob@host - FAILURE
[...]


Mit "h 7" kannst Du zu mail Nummer 7 springen
MIt <Enter> kannst Du die mit ">" gekennzeichnete Mail öffen, mit "q" die mail wieder verlassen,
Mit "x" das Program "mail" beenden.

PinguinPanic
07.11.15, 10:26
Aqualung (http://www.linuxforen.de/forums/member.php?78088-Aqualung)


sudo -s

bash: sudo: Kommando nicht gefunden.

PinguinPanic
07.11.15, 10:28
su
Passwort:
root@debian:/home/andy# mail

No mail for root

PinguinPanic
07.11.15, 10:51
Ein einfaches
andy@debian:~$
mail
im terminal reicht .

Mail version 8.1.2 01/15/2001. Type ? for help.
"/var/mail/andy": 63 messages 63 new
>N 1 root@debian Fri Nov 06 17:01 23/895 Cron <andy@debian> /home/an
N 2 root@debian Sat Nov 07 06:01 23/944 Cron <andy@debian> /home/an
N 3 root@debian Sat Nov 07 09:36 23/944 Cron <andy@debian> /home/an
N 4 root@debian Sat Nov 07 09:37 23/944 Cron <andy@debian> /home/an
N 5 root@debian Sat Nov 07 09:38 23/944 Cron <andy@debian> /home/an
N 6 root@debian Sat Nov 07 09:39 23/944 Cron <andy@debian> /home/an
N 7 root@debian Sat Nov 07 09:40 23/808 Cron <andy@debian> root /ho
N 8 root@debian Sat Nov 07 09:41 23/808 Cron <andy@debian> root /ho
N 9 root@debian Sat Nov 07 09:42 23/808 Cron <andy@debian> root /ho
N 10 root@debian Sat Nov 07 09:43 23/808 Cron <andy@debian> root /ho
N 11 root@debian Sat Nov 07 09:44 23/808 Cron <andy@debian> root /ho
N 12 root@debian Sat Nov 07 09:45 23/808 Cron <andy@debian> root /ho
N 13 root@debian Sat Nov 07 09:46 23/808 Cron <andy@debian> root /ho
N 14 root@debian Sat Nov 07 09:47 23/808 Cron <andy@debian> root /ho
N 15 root@debian Sat Nov 07 09:48 23/808 Cron <andy@debian> root /ho
N 16 root@debian Sat Nov 07 09:49 23/808 Cron <andy@debian> root /ho
N 17 root@debian Sat Nov 07 09:50 23/808 Cron <andy@debian> root /ho
N 18 root@debian Sat Nov 07 09:51 23/808 Cron <andy@debian> root /ho
N 19 root@debian Sat Nov 07 09:52 23/808 Cron <andy@debian> root /ho
N 20 root@debian Sat Nov 07 09:53 23/808 Cron <andy@debian> root /ho
&
Mit deinen Vorschlägen funktioniert es nicht

From andy@debian Sat Nov 07 09:53:01 2015
Envelope-to: andy@debian
Delivery-date: Sat, 07 Nov 2015 09:53:01 +0100
From: root@debian (Cron Daemon)
To: andy@debian
Subject: Cron <andy@debian> root /home/andy/cron.sh > /home/andy/Schreibtisch/cronjobgestratet.txt >/home/andy/Schreibtisch/meinGenialCronJobLog.txt
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/andy>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=andy>
Date: Sat, 07 Nov 2015 09:53:01 +0100

/bin/sh: 1: root: not found

Wie man die email liesst weiss ich nicht.

PinguinPanic
07.11.15, 10:55
]cp: der Aufruf von stat fM-CM-<r M-bM^@M^^/media/andy/ba065390-4414-4743-bce3-3c0609ec68ca/home/internet/SchreibtischM-bM^@M^\ ist nicht mM-CM-6glich: Datei oder Verzeichnis nicht gefunden

PinguinPanic
07.11.15, 14:23
Jetzt muss ich pushen.

PinguinPanic
07.11.15, 15:42
Gelöst ist hiesiger Thread nicht.

Aqualung
07.11.15, 19:04
Dein cronjob ist fehlerhaft:

Es muss:


* * * * * /home/andy/cron.sh


heissen.

marce
07.11.15, 19:30
das kommt drauf an, in welche crontab er sie denn nun eingetragen hat - direkt in die /etc/crontab oder mit crontab -e.

Der Inhalt der Mail deutet aber darauf hin :-)

@ PinguinPanic: Lass bitte das unnötige gepushe. Die Leute kommen schon von selbst und bieten Hilfe an. Freiweillig. Mit derart "Generve" wird die Aussicht auf Hilfe eher geringer. Zudem - verwende für Code bitte die [code]-Tags.