Cron Job to Flush OPcache

  • Answered
Hello. I have a PHP file to flush my OPcache, and created a Cron Job, via cPanel > Cron Jobs, to run that file every 4 hours. Here is the Command:

php -q /home/enxaqu5/public_html/flush-opcache.php

But there is no evidence that it's working - I'm not receiving emails and, when checking my Cron Job via server logs (, as I successfuly connect via SSH through my Mac's Terminal and type: grep "flush-opcache.php" /var/log/cron , I get the message that there is no such file or directory.

All I need is to make sure my OPcache is cleared periodically. Could anyone, please, let me know how to do this?
Hello, Sorry for the problem with flushing your OPCache. If you're not receiving any emails from the server, then you should check that first. What email address was used? Do you see any error messages for the delivery? Test with another email address or try creating a simple test cron job, then run it and make sure that emails are being sent. If they're not then should be resolved first. Once the email issue is resolved, then you can double-check the clearing of your cache cron job. I'm not sure how you're flushing the cache, but please check out the comments in the documentation on flushing the opcache in this link. It may help to clear up the issue if it ends being an issue with the script. I hope that helps to answer your question! If you require further assistance, please let us know! Regards, Arnel C.