Solved Goaccess Script is not executed via cron

I am trying to setup a shell script that creates goaccess reports with cron. When running the script manually it is working. I can see that the shell script is started via cron in cron.log.

Code:
root@p:~ # more /etc/crontab
# /etc/crontab - root's crontab for FreeBSD
#
# $FreeBSD$
#
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
#
#minute hour    mday    month   wday    who     command

51 * * * * root /root/create-goaccess-stats-hb.sh
Unfortunately something within the script is not working. Nothing is written to cron.log or a logfile that the crontask should write to

Any ideas what is wrong with this shell script for cron?
Code:
#!/bin/sh

/usr/bin/more /usr/local/www/www-hb/logs/nx-access.log* | /usr/local/bin/goaccess -  --log-format='%h %^[%d:%t %^]%^"%r" %s %b "%R" "%u" %^' --date-format=%d/%b/%Y --time-format=%T -o  /var/data/www-hb-goaccess/index.html
 
What does /var/log/cron tell you? Also check root's mail, any errors or output from cron scripts are mailed to the user that ran the cronjob.
 
/var/log/cron doesnt tell anything. I finally found some errors in roots spam folder :-(

The error is goaccess specific but it seems that when telling goaccess to use the input via the pipe within cron it is causing trouble to use the rest of the configuration. I will try to find a different way to pipe the logs into goaccess
 
The error is goaccess specific but it seems that when telling goaccess to use the input via the pipe within cron it is causing trouble to use the rest of the configuration. I will try to find a different way to pipe the logs into goaccess
There might be some issues because a cronjob doesn't run on a TTY. I'd just feed the logs to goaccess as an argument, there shouldn't be a need to pipe anything.

goaccess /usr/local/www/www-hb/logs/nx-access.log* will do what you expect it to do.
 
I have now moved all configurations to the default goaccess.conf in /usr/local/etc/goaccess.conf. The script is reduced to
Code:
#!/bin/sh

/usr/local/bin/goaccess -p /usr/local/etc/goaccess/goaccess.conf -o /var/data/www-hb-goaccess/index.html /usr/local/www/www-hb/logs/nx-access.log*
Commandline is working. Cron not

The error is telling me that goaccess from cron doesnt like some formats that are configured in the goaccess.conf.

I currently believe its something wrong with goaccess. I will try to change th subject
 
no luck :-(

Code:
 set |grep ^LC_
LC_ALL=C.UTF-8


Code:
 more /root/create-goaccess-stats-hb.sh
#!/bin/sh
LC_ALL=C.UTF-8
echo $LC_ALL
/usr/local/bin/goaccess -p /usr/local/etc/goaccess/goaccess.conf -o /var/data/www-rc-goaccess/index.html /usr/local/www/www-rc/logs/nx-access.log*
 
no luck :-(

Code:
 set |grep ^LC_
LC_ALL=C.UTF-8


Code:
 more /root/create-goaccess-stats-hb.sh
#!/bin/sh
LC_ALL=C.UTF-8
echo $LC_ALL
/usr/local/bin/goaccess -p /usr/local/etc/goaccess/goaccess.conf -o /var/data/www-rc-goaccess/index.html /usr/local/www/www-rc/logs/nx-access.log*
export LC_ALL
 
export LC_ALL
Or
Code:
#!/bin/sh

env LC_ALL=C.UTF-8 /usr/local/bin/goaccess -p /usr/local/etc/goaccess/goaccess.conf -o /var/data/www-rc-goaccess/index.html /usr/local/www/www-rc/logs/nx-access.log*
 
THATS IT!!!

Code:
#!/bin/sh
LC_ALL=C.UTF-8
export LC_ALL

/usr/local/bin/goaccess -p /usr/local/etc/goaccess/goaccess.conf -o /var/data/www-hb-goaccess/index.html /usr/local/www/www-hb/logs/nx-access.log*

IS WORKING !!!

Thank you very much
 
Back
Top