Cronjob wird nicht ausgeführt
Cronjob wird nicht ausgeführt
Hallo Forum!
Ich habe mir ein Backup-Script für meine SQL-Datenbank geschrieben. Rufe ich es per sh /pfad/zum/skript/skript.sh auf, funktioniert es auch einwandfrei.
Nun wollte ich, dass das Skript täglich um 1 Uhr nachts aufgerufen wird, aber es passiert leider gar nichts.
Ich habe das Skript im Ordner /etc/cron.daily/ gespeichert und mittels crontab -e folgenden cronjob angelegt:
0 1 * * * sh /etc/cron.daily/skript.sh
der zielordner ist schreibbar für die backups, und das skript selbst hat auch 0755 als chmod.
Was mache ich falsch?
Ps: Ich nutze Debian Lenny.
Ich habe mir ein Backup-Script für meine SQL-Datenbank geschrieben. Rufe ich es per sh /pfad/zum/skript/skript.sh auf, funktioniert es auch einwandfrei.
Nun wollte ich, dass das Skript täglich um 1 Uhr nachts aufgerufen wird, aber es passiert leider gar nichts.
Ich habe das Skript im Ordner /etc/cron.daily/ gespeichert und mittels crontab -e folgenden cronjob angelegt:
0 1 * * * sh /etc/cron.daily/skript.sh
der zielordner ist schreibbar für die backups, und das skript selbst hat auch 0755 als chmod.
Was mache ich falsch?
Ps: Ich nutze Debian Lenny.
Re: Cronjob wird nicht ausgeführt
Kann es sein das du Plesk oder Confixx verwendest?
Re: Cronjob wird nicht ausgeführt
Hallo!
Nein, weder noch. Lediglich webmin. Ansonsten hab ich die Konsole :)
Nein, weder noch. Lediglich webmin. Ansonsten hab ich die Konsole :)
Re: Cronjob wird nicht ausgeführt
Scripts in cron.daily werden automatisch täglich ausgeführt, ohne Eintrag per crontab -e.
Zeige das Script bitte mal.
Zeige das Script bitte mal.
PayPal.Me/JoeUser ● FreeBSD Remote Installation
Wings for Life ● Wings for Life World Run
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
Wings for Life ● Wings for Life World Run
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
Re: Cronjob wird nicht ausgeführt
DIR="/var/sql_backups"
mysqldump -uUser -pPasswort wpf > $DIR/backup-`date +%d%m%y`.sql
gzip -9 --best $DIR/backup-`date +%d%m%y`.sql
rm $DIR/backup-`date -d "10 days ago" +%d%m%y`.sql.gz
Bitte schön.
Wie gesagt, wenn ichs per sh skript.sh aufrufe funktioniert es. Was mich stutzig werden lässt ist, dass in cron.daily nur skripte ohne endung liegen. also ohne .sh am ende. Das habe ich auch schon versucht, aber das geht überhaupt nicht :)
mysqldump -uUser -pPasswort wpf > $DIR/backup-`date +%d%m%y`.sql
gzip -9 --best $DIR/backup-`date +%d%m%y`.sql
rm $DIR/backup-`date -d "10 days ago" +%d%m%y`.sql.gz
Bitte schön.
Wie gesagt, wenn ichs per sh skript.sh aufrufe funktioniert es. Was mich stutzig werden lässt ist, dass in cron.daily nur skripte ohne endung liegen. also ohne .sh am ende. Das habe ich auch schon versucht, aber das geht überhaupt nicht :)
Re: Cronjob wird nicht ausgeführt
Das Script ist unvollständig, so passt es eher:
Das .sh am Ende des Dateinamens kannst Du ruhig weglassen, wichtig sind chmod 0755 und die Shebang (erste Zeile im Script).
Code: Select all
#!/bin/sh
DIR="/var/sql_backups"
mysqldump -uUser -pPasswort wpf > $DIR/backup-`date +%d%m%y`.sql
gzip -9 --best $DIR/backup-`date +%d%m%y`.sql
rm $DIR/backup-`date -d "10 days ago" +%d%m%y`.sql.gz
PayPal.Me/JoeUser ● FreeBSD Remote Installation
Wings for Life ● Wings for Life World Run
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
Wings for Life ● Wings for Life World Run
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
Re: Cronjob wird nicht ausgeführt
aha aha, daher weht also der wind! werd ich direkt mal testen! vielen lieben dank!
Re: Cronjob wird nicht ausgeführt
Ja wunderbar. Funktioniert. Nochmals danke!
Re: Cronjob wird nicht ausgeführt
Bitte, gern geschehen und Willkommen im RootForum.
PayPal.Me/JoeUser ● FreeBSD Remote Installation
Wings for Life ● Wings for Life World Run
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
Wings for Life ● Wings for Life World Run
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
