I'm getting an error in my Magento 2.4.2-p1 when I run n98-magerun2 sys:cron:run analytics_collect_data and overnight in the cron table.
Cron-job "analytics_collect_data" threw exception Magento\Framework\Exception\FileSystemException
In File.php line 226:
Directory "/tmp/analytics/tmp" cannot be created Warning!mkdir(): Permission denied
In my development environment I've set the var folder to permissions 777 and manually created the tmp/analytics/tmp folder all with permissions set to 777 but I still get the error.
Here are the steps on how to change the owner of the directory:
chown -R <username> /tmp/analytics/tmp
Replace <username> with the name of the user running the cron job.
Here are the steps on how to change the permissions on the directory:
chmod -R 777 /tmp/analytics/tmp
Replace /path/to/new/directory with the path to the new directory you want to use.
Once you have made the necessary changes, restart the cron job. The cron job should now be able to create the directory and store its files without any errors.
How to navigate to the directory where the cron job is located?