Hi
I have a shell script like that
Main() {
DAY=$(date +"%d-%m-%Y")
TIME=$(date +"%T")
Command 1
Command 2
...
Command n
}
I would like to catch errors from all commands in Main() and write these errors into a file , something likes this:
Main
if < error >
then
echo $DAY $TIME "ERROR:" $ERROR >> error.log
else
echo $DAY $TIME "OK" >> error.log
fi
and file error.log would look like this:
04-05-2015 06:00:00:OK
04-05-2015 07:00:00:OK
04-05-2015 08:00:00:ERROR : < error output ... >
04-05-2015 09:00:00:OK
04-05-2015 10:00:00:OK
Somebody help please