Awstats stderr solution

Hello!

Firts of all, sorry fo my poor english, but i hope you'll undestand me :slight_smile:

Ok, let's go to the problem....

I have a lot of awstats crontabs, and i have one mail,where i get daily and weekly output of all servers that i administrate, now it's problem that i get to his mail every time, when crontab for awstats is started.

I was searching on google so long, but i did't find any fine solution too me, because i don't want to use this in the end of crontab -> CRON >/dev/null 2>&1
because this will email me only if file won't exist anymore.

Finally, i want that crontab for awstats send me email just in case if awstats don't update correcly.

Thank you very much!

Regards

So is there a program or script named "awstats" which is in a crontab? Let's say you have this job running every day at 2:30 am.

2  30  * * * /usr/local/bin/awstats

If you want it to only email you when there's a problem, just do this:

2  30  * * * /usr/local/bin/awstats >/dev/null 2>&1 || echo "awstats failed to complete"

This does require that the script exit with a non-zero condition upon an error. Do you have a way of testing this?

Hmmm.... maybe this'll work, buti don't know if this will alert me, if config file doesn't exit and if update wasn't successfully made?

Test it. Run awstats and force an error condition (one way is to kill the process from another terminal). Then in the command prompt after awstats returns, run

echo $?

If it exited with a non-zero, cron will email you. Make sure cron CAN email you.