Crontab wird nicht ausgeführt?

Dieses Thema im Forum "Linux & BSD" wurde erstellt von Kirill, 8. April 2010 .

Schlagworte:
  1. 8. April 2010
    Hallo Leute,
    ich versuche ein Skript über Crontab ausführen zu lassen. Leider möchte das noch nicht so ganz klappen.

    ###

    Infos:

    [/etc/crontab]

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


    58 21 * * * root bash /scripts/proftpd.sh
    58 21 * * * root bash -x /scripts/proftpd.sh
    58 21 * * * root /scripts/proftpd.sh



    [crontab -e] (/var/spool/cron/crontabs/root)

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


    58 21 * * * root bash /scripts/proftpd.sh
    58 21 * * * root bash -x /scripts/proftpd.sh
    58 21 * * * root /scripts/proftpd.sh

    ###

    Das Skript selber habe ich standardmäßig mit chmod 711 rechten ausgestattet. Chmod 777 hilft hier auch nichts. Das Skript selber lässt sich ohne Probleme ausführen.


    Die [/var/log/syslog] sagt folgendes aus:
    Apr 8 21:58:01 NAS crond[15972]: USER root pid 16360 cmd root bash /scripts/proftpd.sh
    Apr 8 21:58:01 NAS crond[15972]: USER root pid 16361 cmd root bash -x /scripts/proftpd.sh
    Apr 8 21:58:01 NAS crond[15972]: USER root pid 16362 cmd root /scripts/proftpd.sh


    Weiß jemand was das genau heiß bzw. was ich falsch gemacht habe?

    Danke im Voraus!

    Grüße
    Kirill
     
  2. 8. April 2010
    AW: Crontab wird nicht ausgeführt?

    normalerweise sollte das eigentlich so funktionieren, zumindest was syslog angeht. hast du mal versucht was einfaches per cron zu starten?
    irgend n script wie

    #!/bin/bash
    echo "trottel" > /tmp/treppendepp
    exit 0

    über crontab -e zu laden? wird das ausgeführt bzw sieht man das resultat?
     
  3. 8. April 2010
    AW: Crontab wird nicht ausgeführt?

    Also mein Skript ist noch kürzer.

    Die proftpd.sh beinhaltet:
    Code:
    #!/bin/bash
    
    /etc/init.d/proftpd restart
    
    Ich kann aber mal versuchen dein Skript ausführen zu lassen. Melde mich gleich wieder.
     
  4. 8. April 2010
    AW: Crontab wird nicht ausgeführt?

    dann frag ich mich aber, warum du das nicht einfach direkt in die /etc/ crontab schreibst

    * * * * * root /etc/init.d/proftpd restart

    das sollte jede volle minute den proftpd neustarten.
     
  5. 8. April 2010
    AW: Crontab wird nicht ausgeführt?

    Naja das kann ich auch mal versuchen. Geplant ist jedoch das Skript zu erweitern, deswegen versuche ich das gleich als Skript auszuführen.
     
  6. 8. April 2010
    AW: Crontab wird nicht ausgeführt?

    * * * * * root /dein/script.sh

    sollte eigentlich dein script einmal pro minute durchlaufen lassen.
    das bash oder bash -x brauchst du nicht, da du mit #!/bin/bash den kommandozeileninterpreter ja bereits definiert hast. sollte aber eigentlich keinen unterschied machen ... oO
     
  7. 8. April 2010
    AW: Crontab wird nicht ausgeführt?

    So nun habe ich dein Skript probiert, mein Skript direkt in der Crontab rein-zuschreiben und das Ergebnis sieht wie folgt aus:

    [/var/log/syslog]:
    Code:
    Apr 8 22:51:01 NAS crond[24544]: USER root pid 24637 cmd root /etc/init.d/proftpd restart
    Apr 8 22:51:01 NAS crond[24544]: USER root pid 24638 cmd root /scripts/proftpd.sh
    Apr 8 22:51:01 NAS crond[24544]: USER root pid 24639 cmd root /scripts/raidrush.sh
    Apr 8 22:52:01 NAS crond[24544]: USER root pid 24781 cmd root /etc/init.d/proftpd restart
    Apr 8 22:52:01 NAS crond[24544]: USER root pid 24782 cmd root /scripts/proftpd.sh
    Apr 8 22:52:01 NAS crond[24544]: USER root pid 24783 cmd root /scripts/raidrush.sh
    
    Aber kein treppendepp im /tmp und kein restart des proftpd-Daemons.

    Natürlich habe ich davor den Crontab-Daemon neugestartet (/etc/init.d/crond restart).


    Die Ausgabe von crontab -l sagt folgendes aus:
    Code:
    SHELL=/bin/sh
    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    
    # m h dom mon dow user command
    #17 * * * * root cd / && run-parts --report /etc/cron.hourly
    #00 1 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
    #47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
    #52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )i
    * * * * * root /etc/init.d/proftpd restart
    * * * * * root /scripts/proftpd.sh
    * * * * * root /scripts/raidrush.sh
    
     
  8. 8. April 2010
    AW: Crontab wird nicht ausgeführt?

    du meintest doch sicher /etc/init.d/cron reload oder?

    .... natürlich meinter das.

    probier mal alles über die /etc/crontab datei zu machen und nix mit crontab -l oder -e rumzuhantieren. ich schreib auch immer alles direkt in die crontab und da gings bisher ...
     
  9. 8. April 2010
    AW: Crontab wird nicht ausgeführt?

    Ja.

    Edit:
    Was ich noch dazu sagen muss, dass es eine NAS-Platte ist, die eine minimale Installation von Debian Lenny 5.0 besitzt. Irgendwie funktioniert hier auch kein locate oder search.

    Code:
    -sh: locate: command not found
    

    Edit:
    So nun ist alles in der /etc/crontab und das Ergebnis sieht nun wie folgt aus:
    Dass die /var/log/syslog nichts mehr ausgibt, sprich die /etc/crontab wird gar nicht ausgeführt.


    [/etc/crontab]:
    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
    # and files in /etc/cron.d. These files also have username fields,
    # 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
    #17 * * * * root cd / && run-parts --report /etc/cron.hourly
    #25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
    #47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
    #52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
    * * * * * root /etc/init.d/proftpd restart
    * * * * * root /scripts/proftpd.sh
    * * * * * root /scripts/raidrush.sh
    
     
  10. 8. April 2010
    AW: Crontab wird nicht ausgeführt?

    Was suchst du denn?

    btw. workaround:
    find / suchbegriff | grep suchbegriff

    (ja suchbegriff is doppelt)
     
  11. 8. April 2010
    AW: Crontab wird nicht ausgeführt?

    Ich habe mal was gesucht und dabei ist mir dann aufgefallen, dass die Befehle locate und search nicht vorhanden sind.

    Die /var/log/syslog gebe ich mir mit dem Befehl:
    Code:
    tail -10 /var/log/syslog
    
    aus.
     
  12. Video Script

    Videos zum Themenbereich

    * gefundene Videos auf YouTube, anhand der Überschrift.