Page 1 of 1

Сron email notification [SOLVED]

Posted: Mon 20. Apr 2020, 11:02
by majorboobage
Here's the thing.

I am using goaccess with cron:

Code: Select all

/usr/local/bin/goaccess -p /usr/local/etc/goaccess/goaccess.conf -a - /home/users/USERNAME/logs/access.log -o  /home/users/USERNAME/www/mysite.com/access.html
Image

Notification: On Errors

As you can see, the task completed without errors (Success).
But each time, after completing the task, a letter arrives.
Image

So, if the operation is completed successfully, why does the letter come? :?

Re: Сron email notification (probably a bug)  [SOLVED]

Posted: Mon 20. Apr 2020, 12:33
by Alexander
Hello,

it's seams not a bug, at least from the KeyHelp perspective.

The reason you receive the message is, that the goaccess script seams to writes its output ("Parsing... [258] [0/s]....") not into the normal "stdout" (Standard Output Stream) instead to the "stderr" (Standard Error Stream).
If the cron daemon, responsible for executing cron jobs, detects a non empty "stderr" it considered it as an unsuccessful execution of the script, even if the return code of the script was 0 (which means success).

For fixing this behavior, you can redirect the stderr stream of the goaccess script to the stdout stream by appending " 2>&1" to the command within KeyHelp (without the quotation marks of course).

===

For verifying, my above assumption is correct, please have a look into the crontab config file via "crontab -u <NAME_OF_THE_KEYHELP_USER> -l".
Right now, the command should look like:

Code: Select all

[...] /usr/local/bin/goaccess -p /usr/local/etc/goaccess/goaccess.conf -a - /home/users/USERNAME/logs/access.log -o  /home/users/USERNAME/www/mysite.com/access.html > /dev/null
After you have done the fix mentioned above, it should look like:

Code: Select all

[...] /usr/local/bin/goaccess -p /usr/local/etc/goaccess/goaccess.conf -a - /home/users/USERNAME/logs/access.log -o  /home/users/USERNAME/www/mysite.com/access.html 2>&1 > /dev/null

Re: Сron email notification [SOLVED]

Posted: Mon 20. Apr 2020, 18:05
by majorboobage
Hi.

it worked! thank you very much Alexander!

p.s yes, looks like it is old bug/feature :? https://github.com/allinurl/goaccess/issues/467