Auto-archiving scheduled cron error

Hi everyone

I am on Ubuntu 22.04, Matomo latest version, PHP 8.3, and I have an issue with Auto-archiving reports cron not working as it should.

I keep getting this popup but the websites has traffic to it all the time:

My /etc/cron.d/matomo-archive file has multiple archivers setup in the file:

MAILTO="youremail@example.com"
5 * * * * domain.com /usr/bin/php /path/to/matomo/console core:archive --url=https://www.domain.com/matomo/ > /dev/null
6 * * * * domain.com /usr/bin/php /path/to/matomo/console core:archive --url=https://www.domain.com/matomo/ > /dev/null
7 * * * * domain.com /usr/bin/php /path/to/matomo/console core:archive --url=https://www.domain.com/matomo/ > /dev/null
8 * * * * domain.com /usr/bin/php /path/to/matomo/console core:archive --url=https://www.domain.com/matomo/ > /dev/null
9 * * * * domain.com /usr/bin/php /path/to/matomo/console core:archive --url=https://www.domain.com/matomo/ > /dev/null
10 * * * * domain.com /usr/bin/php /path/to/matomo/console core:archive --url=https://www.domain.com/matomo/ > /dev/null

I also got this file /etc/cron.d/0hourly setup to run hourly jobs

# Run the hourly jobs
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
1 * * * * root run-parts /etc/cron.hourly

The user setup looks to be correct, when I run the manual command to archive reports it works.

I tried this:

sudo systemctl restart cron

the I checked the logs to see if I am getting any errors for cron jobs:

journalctl -u cron | grep matomo-archive

and surprise surprise, I am getting this error:

Nov 26 02:07:01 my.server cron[680521]: (*system*matomo-archive) RELOAD (/etc/cron.d/matomo-archive)
Nov 26 02:07:01 my.server cron[680521]: (*system*matomo-archive) ERROR (Missing newline before EOF, this crontab file will be ignored)
Nov 26 02:19:30 my.server cron[2819933]: Error: bad username; while reading /etc/cron.d/matomo-archive
Nov 26 02:19:30 my.server cron[2819933]: (*system*matomo-archive) ERROR (Syntax error, this crontab file will be ignored)
Nov 26 02:21:01 my.server cron[2819933]: (*system*matomo-archive) RELOAD (/etc/cron.d/matomo-archive)
Nov 26 02:36:01 my.server cron[2823991]: (*system*matomo-archive) RELOAD (/etc/cron.d/matomo-archive)
Nov 26 02:43:01 my.server cron[2830266]: (*system*matomo-archive) RELOAD (/etc/cron.d/matomo-archive)

The user rights are correct though, and i have a new line at the end of the file.

Any idea what I am missing here?
I’m scratching my head : /

PS: Note that my username is domain.com and it might be conflicting for Linux commands, but I never had this issue a few months ago, and I had similar usernames as domain.com.

Hi @metrprime
I don’t understand: your crontabs seem launch command evry hour at xx:05:00, xx:06:00, xx:07:00, xx:08:00, xx:09:00, xx:10:00 for the first one, and at xx:01:00 for the other one. Your log does not match this setting (except Nov 26 02:07:01)

I’ve deleted the /etc/cron.d/0hourly file, and restarted the cron job, but getting same error.

Though in Matomo dashboar > Log Viewer i am not seeing any more errors there, just some from a few hrs ago.

I wonder the command every hour was the file above, and the 5th minute, 6th minute etc is the one from here:

5 * * * * domain.com /usr/bin/php /path/to/matomo/console core:archive --url=https://www.domain.com/matomo/ > /dev/null
6 * * * * domain.com /usr/bin/php /path/to/matomo/console core:archive --url=https://www.domain.com/matomo/ > /dev/null

Update on this:

I’ve run same commands again:

sudo systemctl restart cron
journalctl -u cron | grep matomo-archive

and getting same error now, it looks like the daate did not change at all, still Nov 26 02:07:01:

Nov 26 02:07:01 my.server cron[680521]: (*system*matomo-archive) RELOAD (/etc/cron.d/matomo-archive)
Nov 26 02:07:01 my.server cron[680521]: (*system*matomo-archive) ERROR (Missing newline before EOF, this crontab file will be ignored)
Nov 26 02:19:30 my.server cron[2819933]: Error: bad username; while reading /etc/cron.d/matomo-archive
Nov 26 02:19:30 my.server cron[2819933]: (*system*matomo-archive) ERROR (Syntax error, this crontab file will be ignored)
Nov 26 02:21:01 my.server cron[2819933]: (*system*matomo-archive) RELOAD (/etc/cron.d/matomo-archive)
Nov 26 02:36:01 my.server cron[2823991]: (*system*matomo-archive) RELOAD (/etc/cron.d/matomo-archive)
Nov 26 02:43:01 my.server cron[2830266]: (*system*matomo-archive) RELOAD (/etc/cron.d/matomo-archive)

So far so good, not seeing the Archiving popup anymore.
Also I removed the 0hourly file and seems that this did not affect the crontab running.

Hi @metrprime

You should end each crontab line with an end of line (Return key) in order to be taken into account…

Got it thanks!

I’ve ended up re-installing Matomo on this and not getting the error anymore, fixed the file as you said too.

Thank you!

1 Like