0

I'am using the Ubuntu 14.04 (Trusty) version and i get a problem with my crontab (it was working before 13.10)

Here is the command line

/usr/lib/cgi-bin/awstats.pl -config=www.skrik.fr -update >/dev/null

If i run it as root in my terminal i get no error everything is working smoothly

But if i add it with sudo crontab -e i get

0 * * * * root /usr/lib/cgi-bin/awstats.pl -config=www.skrik.fr -update >/dev/null

Error while processing /etc/awstats/awstats.cloud.skrik.fr.conf Create/Update database for config "/etc/awstats/awstats.cloud.skrik.fr.conf" by AWStats version 7.2 (build 1.992) From data in log file "/var/log/apache2/cloud/access.log"... Error: Couldn't open server log file "/var/log/apache2/cloud/access.log" : Permission denied

I get the exact same problem when i add it to /etc/crontab

Why cron job doesn't want to work as root ?

Thanks a lot for your help

  • @Danatela I'm not 100% sure if it's a bug. I'm not sure what the problem is, but the inconsistencies suggest that something else is wrong, IMO. – Sparhawk Apr 9 '14 at 10:50
  • Hum the problem seems to be the new logrotate of apache. I will test new permission and come back to you. bugs.launchpad.net/ubuntu/+source/awstats/+bug/1252467 – Lezin Apr 9 '14 at 10:55
  • 2
    please put the solution in an answer below, we want to sepperate the question form the answer. Or it will be confusing for future visitors. – Alvar Apr 9 '14 at 11:23
  • @Lezin I'm glad you found the answer! However, please move it to the answer section below, and then accept it when you can with the tick (I think you have to wait 24 hours). It's totally okay to answer your own questions! Cheers, and welcome to AskUbuntu! – Sparhawk Apr 9 '14 at 11:23
  • 1
    You will have to wait until tomorrow to accept your answer but you can post it now. – terdon Apr 9 '14 at 15:22
0

Solution

Here is the problem :

There is a awstats jobs setup on /etc/cron.d which is run with www-data. This one is causing the problem cause www-data doesn't have access to /var/log/apache2

First you need to :

chmod o+rx /var/log/apache2

Next you need to change on /etc/logrotate.d/apache2

create 640 root adm

Into:

create 644 root adm

restart the service.

My /etc/crontab was working fine. But i prefer to run the script with a non root accound.

  • Just curious to know why +x is needed here? I thought it was only about read access. Is there another meaning behind 'execute' – H.Rabiee Jul 25 '16 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.