#!/bin/bash # Proper header for a Bash script. # Cleanup, version 2 # Run as root, of course. # Insert code here to print error message and exit if not root. LOG_DIR=/var/log # Variables are better than hard-coded values. cd $LOG_DIR cat /dev/null> messages cat /dev/null> wtmp echo "Logs cleaned up." exit # The right and proper method of "exiting" from a script. # A bare "exit" (no parameter) returns the exit status #+ of the preceding command.
Wenn man seine Cron Jobs genauer untersuchen möchte ist es sinnvoll, die Logs in eine eigene Datei =cron.log zu schreiben
Weiters ist es oft sinnvoll, den Output des Cron Jobs in ein eigenes Log zu schreiben. Die Zeile in der Crontab ist zu erweitern:
>> /home/log/myscript.log 2>&1