02.Dec.08Quiet grepUsually during an cron job, one needs to check for an expression in a log file, or in the output of a command, without generating any cumbersone new output (such as a standard grep would do): this is exactly the use of the -q option of grep. For example: for i in `grep -v '^#' /etc/passwd | cut -f1 -d:` grep $i /var/log/samba/log.smbd | grep -q 'failed to authenticate' if [ $? == 0 ] ; then mail -s 'Error in samba' $i <<EOM ...
23.Oct.08Nix all output$ cat /var/mail/* >/dev/null 2>&1 The first redirect sends stdout to /dev/null, the second one sends stderr to stdout, thus making all the output disappear. Useful in cron jobs if you want no mail sent.