die jeden tag um 2 Uhr nachts ausgeführt wird.
Code: Alles auswählen
0 2 * * * shutdown -h now >/dev/null 2>&1
Code: Alles auswählen
0 2 * * * shutdown -h now >/dev/null 2>&1
Was zeigt:Leon hat geschrieben: ↑Montag 12. August 2019, 23:16 Hi, ich wollte eine einfache Cron erstellen,
die jeden tag um 2 Uhr nachts ausgeführt wird.
Nur leider wird auch hier nichts ausgeführt.Code: Alles auswählen
0 2 * * * shutdown -h now >/dev/null 2>&1
Code: Alles auswählen
systemctl status cronie
Code: Alles auswählen
systemctl status cronie
● cronie.service - Periodic Command Scheduler
Loaded: loaded (/usr/lib/systemd/system/cronie.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2019-08-13 11:35:17 CEST; 1h 34min ago
Main PID: 401 (crond)
Tasks: 1 (limit: 4915)
Memory: 5.5M
CGroup: /system.slice/cronie.service
└─401 /usr/bin/crond -n
Aug 13 12:01:01 NASXZERO anacron[717]: Will run job `cron.monthly' in 56 min.
Aug 13 12:01:01 NASXZERO anacron[717]: Jobs will be executed sequentially
Aug 13 12:17:01 NASXZERO anacron[717]: Job `cron.daily' started
Aug 13 12:17:01 NASXZERO anacron[717]: Job `cron.daily' terminated
Aug 13 12:37:01 NASXZERO anacron[717]: Job `cron.weekly' started
Aug 13 12:37:02 NASXZERO anacron[717]: Job `cron.weekly' terminated
Aug 13 12:57:01 NASXZERO anacron[717]: Job `cron.monthly' started
Aug 13 12:57:02 NASXZERO anacron[717]: Job `cron.monthly' terminated
Aug 13 12:57:02 NASXZERO anacron[717]: Normal exit (3 jobs run)
Aug 13 13:01:01 NASXZERO CROND[2027]: (root) CMD (run-parts /etc/cron.hourly)
Code: Alles auswählen
Message-Id: <E1hxV4v-0001kr-DO@mexiko.fritz.lokal>
Date: Tue, 13 Aug 2019 13:35:01 +0200
shutdown: you must be root to do that!
Code: Alles auswählen
20 13 * * * root shutdown -h now
Code: Alles auswählen
18 15 * * * root shutdown -h now
Das habe ich mich im Stillen auch gefragt und weiss es nicht, bzw. kann nur Vermutungen anstellen:
Code: Alles auswählen
ls -l /sbin/shutdown
Code: Alles auswählen
-rwsr-sr-x 1 root root 23K 2017-02-12 22:55 /sbin/shutdown
Nun, ich nutze kein systemd, kann dazu also nichts sagen, außer das ich systemd alles zutraue...
Code: Alles auswählen
shutdown -h
Ich finde die Lösung durchaus nicht "dirty", sondern eigentlich ganz elegant, weil es nicht "doppelt gemoppelt" ist wie bei cronie:
Hm, bei mir funktioniert das, keine Ahnung, warum bei dir nicht. Du sprichst jetzt auch von der /etc/crontab? Am Ende steht auch eine Leerzeile oder ein Kommentar?
Naja, ich lasse mir Mails vom Cronjob schicken, dazu braucht man aber einen Mail Transfer Agent, wie z.B. postfix. Aber soviel ich weiss kannst Du ja Ausgaben auch in eine Datei umleiten, wie Du es ja schon am Anfang gemacht hast, nur eben nach /dev/null. Ersetze das durch eine beliebige Datei, z.B. ~/cronie.log und Du solltest Ausgaben haben.
auf der Kommandozeile ist das Kommando etwas kryptisch
Code: Alles auswählen
kcmshell5 kcm-cron
Code: Alles auswählen
kcmshell5 kcm_cron