A bash script is run from cron, stderr is redirected to a logfile, this all works fine. The code is:
*/10 5-22 * * * /opt/scripts/sql_fetch 2>> /opt/scripts/logfile.txt
I want to prepend the date to every line in the log file, this does not work, the code is:
*/10 5-22 * * * /opt/scripts/sql_fetch 2>> ( /opt/scripts/predate.sh >> /opt/scripts/logfile.txt )
The predate.sh script looks as follows:
#!/bin/bash
while read line ; do
echo "$(date): ${line}"
done
So the second bit of code doesn't work, could someone shed some light? Thanks.