Hi,
The issue with sed is it does nothing if stdin is empty.
I think I found a not too bad fix, still not perfect. I replaced the lines 92 to 94 in /usr/bin/run-parts:
Code:
$i | sed '1i\
'"$i"':\
'
With these:
Code:
if result=$($i 2>&1); then
[[ -n "$result" ]] && echo -e "$i finished successfully:\n\n$result"
else
echo -e "$i finished with error(s):\n\n$result" 1>&2
fi
With this crontab:
Code:
47 * * * * /usr/bin/run-parts /etc/cron.hourly
stdout and stderr are sent by mail as expected with the name of the jobs and report if the job is done successfully or with error.
With this crontab:
Code:
47 * * * * /usr/bin/run-parts /etc/cron.hourly 1> /dev/null
a mail is sent only if a job failed but stdout and stderr are both sent.
Right now I didn't find a good way to send only stderr, but it's a start.