cancel
Showing results for 
Search instead for 
Did you mean: 

Magento Clear Cache Cron

Magento Clear Cache Cron

I have a magento website running on ver. 2.2.1 which is hosted on Plesk server, I am looking at setting up a scheduled task (cron) to flush the magento cache every other day at midnight.

 

Is this possible and can anyone help with how I can set this up?

4 REPLIES 4

Re: Magento Clear Cache Cron

@CraigLambo 

 

Easiest way, 

 

Just create a bash file, i.e. cache.sh file and put this file on Magento root folder. Keep below content in this file:

php bin/magento cache:flush
* * * * * sh /home/magento/cache.sh

Later on you can set like this according to your time.

Manish Mittal
https://www.manishmittal.com/

Re: Magento Clear Cache Cron

Hi @CraigLambo 

Steps to setup cron tab as below:
run the following command line to update the cronjob table:

crontab -e 

Add the following lines to your crontab file:

*/1 * * * * php -c {php.ini_path} {magento_path}/bin/magento cron:run
*/1 * * * * php -c {php.ini_path} {magento_path}/update/cron.php
*/1 * * * * php -c {php.ini_path} {magento_path}/bin/magento setup:cron:run
*/1 * * * * php -c {php.ini_path} {magento_path}/bin/magento cache:flush

Or
For setup cron tab kindly refer below link :
https://www.mageplaza.com/kb/how-to-configure-cronjob-schedule-tasks-magento-2.html

If issue resolve, please click on 'Kudos' & Accept as Solution!

Problem solved? Click Accept as Solution!

Re: Magento Clear Cache Cron

Thank you that works

Re: Magento Clear Cache Cron

To set up a cron job in Plesk to clear the Magento cache every other day at midnight:

  1. Log into Plesk and go to Scheduled Tasks under your domain.
  2. Click Add Task.
  3. Choose Run a command as the task type.
  4. In the command field, input the appropriate command to clear the cache (replace with your Magento path).
  5. Set the schedule to Every other day at 00:00 (midnight).
  6. Save the task.

This will clear your Magento cache automatically every other day at midnight.