Cronjobs
Quelle: https://superuser.com/questions/81262/how-to-execute-shell-script-via-crontab/123894#123894
Einführung
Making crontab running is easy only . Here I am going to say how to run crontab jobs. It is useful for anyone who is stuck on crontab.
*/1 * * * * cd /home/hacks && sh notify.sh
To make the script executable, we have to do:
chmod +x home/hacks/notify.sh
Here i run this script for every one minute ... By doing below script, you can write it in a log file to find whether its working
write log
*/1 * * * * cd /home/hacks && sh notify.sh>>test.log
send mail
*/1 * * * * cd /home/hacks && sh notify.sh>>test.log | mail -s "Hi this is example" [email protected]
Den Server jeden Abend automatisiert herunterfahren
server:/ cat /etc/cron.d/shutdown
#tägliches Herunterfahren um 23:00 Uhr
#00 23 * * * root /sbin/shutdown -h now > /dev/null 2>&1
#Montag-Donnerstag um 00:00 Uhr herunterfahren
#00 23 * * 1-4 root /sbin/shutdown -h now > /dev/null 2>&1
0 0 * * 1-4 root date >> /var/log/_shutdown/shutdown.log
0 0 * * 1-4 root /bin/echo "Fritschserver wird heruntergefahren" >> /var/log/_shutdown/shutdown.log
0 0 * * 1-4 root /sbin/shutdown -h now > /dev/null 2>&1
#Freitag-Samstag um 01:00 Uhr herunterfahren
#00 01 * * 5-6 root /sbin/shutdown -h now > /dev/null 2>&1
0 01 * * 5-6 root date >> /var/log/_shutdown/shutdown.log
0 01 * * 5-6 root /bin/echo "Fritschserver wird heruntergefahren" >> /var/log/_shutdown/shutdown.log
0 01 * * 5-6 root /sbin/shutdown -h now >> /dev/null 2>&1
#Sonntag um 23:00 Uhr herunterfahren
#00 23 * * 7 root /sbin/shutdown -h now > /dev/null 2>&1
#00 00 * * 7 root /sbin/shutdown -h now > /dev/null 2>&1
0 23 * * 7 root date >> /var/log/_shutdown/shutdown.log
0 23 * * 7 root /bin/echo "Fritschserver wird heruntergefahren" >> /var/log/_shutdown/shutdown.log
0 23 * * 7 root /sbin/shutdown -h now >> /dev/null 2>&1