0

I'm running a fresh Magento2.3 install on ubuntu 18.04.

I managed to edit sample data yesterday, but today I had a go at adding a new product.

After saving - I got the error :

One or more indexes are invalid. Make sure your Magento cron job is running.

I found the following thread: Magento 2 Reindexing - One or more indexers are invalid. Make sure your Magento cron job is running

Which suggested running indexer by hand -

php bin/magento indexer:info

When I do I get the error

cache_dir "/var/www/html/Magento2/var/cache/" is not writable

When I check the permissions, they look correct:

greg@VM1:/var/www/html/Magento2/var$ ls -l total 32 drwxrwxr-x 19 www-data www-data 4096 Jun 26 15:01 cache

www-data is as I understand my apache2 user and would be the user that is accessing the cache?

I can run the command from superUser, but it doesn't seem like the way is supposed to work?

Edit I've managed to run these commands by running them as root, but my understanding is they should be being run automatically when any changes are made that requires the indexes to be rebuilt, unless it being done by Cron job. I've got the store set to rebuild them on save.

  • Please check with this: chmod -R 777 var/ generated/ pub/ – Ravi Soni Jun 28 at 13:15
  • i understand you assign cache permission, but can you please verify to cache inside file which permission have. – Anas Mansuri Jun 28 at 13:21
  • Try this: sudo -u www-data php bin/magento indexer:info – Sukumar Gorai Jun 28 at 13:24
  • From which user are you trying to execute the command. what error do you get when you run the command as a root user? – Raj Mohan R Jun 28 at 14:18
0

Need to set permission to var/cache folder

find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
find var pub/static pub/media app/etc generated/ -type f -exec chmod g+w {} \;
find var pub/static pub/media app/etc generated/ -type d -exec chmod g+ws {} \;
chown -R <Magento user>:<web server group> .
chmod u+x bin/magento

For immediate solution(Not recommended)

sudo chmod 777 -R var/cache
0

Had a very similar issue as you. A month ago, our reindexing cron job just stopped according to created_at date in the database. We have ours configured as 'reindex on save', yet still, the site would need to be constantly reindexed manually with the ./magento indexer:reindex command

Investigating further, when we tried a ./magneto cron:run command we got the error message:

"cache_dir "/var/www/html/somewebpage.com/var/page_cache" is not writable" The crontabs we had configured could not access this folder due to permissions.
Solution in our case was simply to chmod 777 the var/page_cached folder.

Check the cron_schedule table in the database to make sure your cron scheduled tasks are running. Even if you are configured in the admin to reindex on save, this should be logging recent events. Ours was firing a reindex action every minute, but stopped a month ago, which clued us in.

SSH into your server as root and verify cron is running. pgrep cron to get the pid and ps -ef to verify, should do the trick.

Go to the var folder. Verify the current permissions of the cache folder or page_cache folder with ls -l. Ours was set to 655. enter image description here

Note the current permissions in case you need to revert.

chmod the folder to 777. I wouldn't worry about doing it recursively (-r) unless you have to.
e.g., chmod 777 page_cache

Switch now to the magento user su magento.
Run the cron:run magento command -- e.g., ./magento cron:run Verify that it now says "Ran jobs by schedule" instead of the cache folder not being writable.
Type exit to get back to root. Run a flush ./magento cron:flush

Now go back to the database cron_schedule table and verify the scheduled indexer cron jobs are now working with recent scheduled cron tasks.

0

Try in sudo su mode, it solved for me. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.