Сron email notification [SOLVED]  [SOLVED]

Locked
majorboobage
Posts: 37
Joined: Thu 26. Jul 2018, 08:51

Сron email notification [SOLVED]

Post 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? :?
Last edited by majorboobage on Mon 20. Apr 2020, 18:06, edited 1 time in total.
User avatar
Alexander
Keyweb AG
Posts: 3810
Joined: Wed 20. Jan 2016, 02:23

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

Post 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
Mit freundlichen Grüßen / Best regards
Alexander Mahr

**************************************************************
Keyweb AG - Die Hosting Marke
Neuwerkstr. 45/46, 99084 Erfurt / Germany
http://www.keyweb.de - http://www.keyhelp.de
**************************************************************
majorboobage
Posts: 37
Joined: Thu 26. Jul 2018, 08:51

Re: Сron email notification [SOLVED]

Post 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
Locked