Cronjob not running in www-data

Hello,
I have set up Piwik to archive using cron. When testing the command on the CLI it works (a different user than www-data) but the cronjob doesn’t execute. I believe this is because the user www-data is not allowed to log in, could this be?
I guess that the cronjob would work if I ran it as root, but I don’t like that idea for security reasons.

Has anybody got a solution here?

Could you redirect the output of this cron job to a file and check what’s there? It should work with both users, since this task is forcing superuser privileges.

Important note: cron user should have write permissions to the tmp directory (the one in Piwik root folder). Try to clear tmp/* before running this task and make sure that you always manually execute archiving as the same user.

One way to “test” correctly the commands in the cron job is simply test it as www-data. That is

su to become root (or sudo su in the case of ubuntu-based distro)
and then

su -s /bin/bash www-data

Then you can really test your commands as www-data, and see why things fail. But, if I remember correctly,
some commands can fail from cron because of issues related to stdin, stdout, or stderr which doesn’t exist, so sometimes you have to add

[code]

/dev/null 2>&1
[/code] at an appropriate place.

Hello,
first off the tmp/* files are owned by www-data. As stated in the official documentation I am writing the output into a file (which is empty and the reason I believe that it’s not working): > /home/example/piwik-archive.log

I have tested the command with

sudo su www-data -c "..."

But I receive the error Cannot log into this account. If I only try su www-data there is the problem that www-data has no password.

In this case I will go for running the cron with root. If this doesn’t work, I will be back.