How to log errors of all scripts executed via cron to one file?
To achieve such feature I prepared mix which is to be used in both script and cron
The example:
crontab -l
CRON_ERR=/var/log/overseer.log
* * * * * YourScript.sh 2>>$CRON_ERR || echo "[`date`] YourScript.sh" >>$CRON_ERR 2>&1
As I have already mentioned you have to modify your script either
#!/bin/bash
set -E
GLOBAL_ERR=0
trap "GLOBAL_ERR=127" ERR
[... your instructions]
exit $GLOBAL_ERR
No comments yet.