Set up Cron not working at all


I have Matomo self-hosted installed on a server that runs Rocky Linux 8.7 and these specs

Matomo version: 4.14.1
MySQL version: 10.3.35-MariaDB
PHP version: 8.1.17

and I am trying to fix this recommendation in Administration > Diagnostic > System Check:

Set up Cron (faster report-loading)
For optimal performance and a speedy Matomo, it is highly recommended to set up a crontab to automatically archive your reports, and to disable browser triggering in the Matomo settings. Learn more."

I followed the guide here , created the /etc/cron.d/matomo-archive file and tweaked these lines:

5 * * * * www-data /usr/bin/php /path/to/matomo/console core:archive --url= > /home/example/matomo-archive.log

I added my own email and for the 2nd line I tried to find the correct paths, where is the domain I used to set it up on:

  • www-data is supposed to be an user but in my case the username created for this domain has the same name as the domain, so it was
  • /usr/bin/php i checked it using which php and got the same path
  • /path/to/matomo/console in my case I figured out it is /home/ (I created a subfolder analytics where I installed Matomo instead of root)
  • is my Matomo URL path:
  • /home/example/matomo-archive.log is this path I figured /home/

So my final 2 code lines that I updated inside file /etc/cron/d/matomo-archive became:

5 * * * * /usr/bin/php /home/ core:archive --url= > /home/

In the instructions it says

/path/to/matomo/console is the path to your Matomo app on your server. For example it may be /var/www/matomo/console

I am not sure if my path is correct to be honest, as I couldn’t find anything in /var/www/matomo : (

So then I modified this command as per guide above:

su www-data -s /bin/bash -c "/usr/bin/php /path/to/matomo/console core:archive --url="

to this command:

su -s /bin/bash -c "/usr/bin/php /home/ core:archive --url="

and ran it in the terminal in order to test if the crontab is working; when I ran it in the terminal, nothing happened, it did not give any error or message or showed any domains.

I think I have made a mistake somewhere but I keep going back and can’t find the solution to this.

I’ve really tried different things to fix this but I still can’t get the crontab working. I even tried changing the username in the file to root and ran the same command with su root -s ... but no success either.

If anyone has any advice on this how to get the crontab working, would be soo grateful!

Thank you so much!


Fixed it finally, I found the solution, it was starring in my face the whole time.

For other Matomo users that encountered similar issues, this is the workaround it:

As per instructions here you will create a file in /etc/cron.d/matomo-archive with 2 lines of code:

5 * * * * /usr/bin/php /path/to/matomo/console core:archive --url= > /dev/null
  • As you can see no need to add the user in the 2nd line of code

As I am setting up the crontab as a user, I’ve used the 2nd line instead of using root.

The trick is that there is actually a folder in your /path/to/matomo/console (duh!).

To test it, go to your terminal SSH and run:

su user_used -s /bin/bash -c "/usr/bin/php /path/to/matomo/console core:archive --url="

The user_used would be usually the user you’ve setup for the webserver, so check it in Scheduled Cron Jobs if unsure, or check in your settings when you’ve created the server.

Once you run the command above, you will see it all green and nice in SSH, meaning it is working : )

Hope this helps other users.