Piwik cron email only on error

Hi all,

I’ve setup some cronjobs which imports my log files daily into a dev system which runs along side my normal system. The regular one uses the javascript code to track normally, the “dev” system is really only for comparison.

I’m using the code below which is included in a file in /etc/cron.daily/:


python /path/to/piwik/misc/log-analytics/import_logs.py --url=https://piwikdev.example.com/ --enable-reverse-dns --recorders=4 --enable-bots --useragent-exclude='check_http/v1.4.16 (nagios-plugins 1.4.16)' --useragent-exclude='Apache (internal dummy connection)'  --add-sites-new-hosts /var/log/piwik/access_log-$(date +%Y%m%d).gz
php /path/to/piwik/misc/cron/archive.php --url=https://piwikdev.example.com/

Now my cron sends me emails daily when this runs and it’s interesting to see the info but not really needed, is there a way I can get this to maybe log to a file but send me a email if something does error or go wrong?

Any help would be great!

Cheers,
Mooash

If you set the cron as explained in: How to Set up Auto-Archiving of Your Reports - Analytics Platform - Matomo

maybe it works ? (eg. append " > /path/to/file " to the cron)

Possibly, however I believe that will just log everything to the file, including the errors? I’m not 100% sure. I’ll try and get it to error.

It shouldn’t. the errors should be logged to the error stream so should send an email if the cron fails