Ab und an benötigt man einen Cronjob der auch unter einer Minute ausgeführt werden soll, ohne sich erst ein Bashscript mit Loop basteln zu müssen. Der Trick dabei ist der „sleep“-Befehl im crontab und dass man den Eintrag mehrfach vornehmen muss.
Möchte man ein Script alle 30 Sekunden ausführen, trägt man folgendes ein:
1 2 |
* * * * * myuser ( /path/to/your/script.sh ) * * * * * myuser ( sleep 30; ( /path/to/your/script.sh ) ) |
Möchte man ein Script alle 5 Sekunden ausführen lassen, wird es schon etwas umfangreicher – Bspw.:
1 2 3 4 5 6 7 8 9 10 11 12 |
* * * * * myuser ( /path/to/your/script.sh ) * * * * * myuser ( sleep 5; ( /path/to/your/script.sh ) ) * * * * * myuser ( sleep 10; ( /path/to/your/script.sh ) ) * * * * * myuser ( sleep 15; ( /path/to/your/script.sh ) ) * * * * * myuser ( sleep 20; ( /path/to/your/script.sh ) ) * * * * * myuser ( sleep 25; ( /path/to/your/script.sh ) ) * * * * * myuser ( sleep 30; ( /path/to/your/script.sh ) ) * * * * * myuser ( sleep 35; ( /path/to/your/script.sh ) ) * * * * * myuser ( sleep 40; ( /path/to/your/script.sh ) ) * * * * * myuser ( sleep 45; ( /path/to/your/script.sh ) ) * * * * * myuser ( sleep 50; ( /path/to/your/script.sh ) ) * * * * * myuser ( sleep 55; ( /path/to/your/script.sh ) ) |