3

I checked in cron_schedule table, cron are disabled. I want to enable or disable crons. How can I do that?

  • do you want to set CRON job ? – Pawan May 22 at 5:26
  • actually I'm working on existing site, on staging all crons are disabled I just want to start them.. – Prashant Patil May 22 at 5:27
  • just run cron:run command to start cron – fmsthird May 22 at 5:28
  • @magefms can this runs crons by schedule? – Prashant Patil May 22 at 5:28
  • 1
    yes checking.. thank you :) – Prashant Patil May 22 at 5:33
3

You can use:

php bin/magento cron:install

Above command will Generates and installs crontab for current user

Screen Shot

  • for disable CRON you can use cron:remove. – Pawan May 22 at 5:44
  • Ok. I also ran the cron:run command.. it set the schedule in cron_schedule table.. but it not runs automatically? – Prashant Patil May 22 at 5:53
  • have you ran cron:install ? as per my screen shot. – Pawan May 22 at 6:03
  • yes.. it shows me error : Error during saving of crontab: You are not allowed to use this program (crontab) – Prashant Patil May 22 at 6:07
  • Are you logged in as root ? – Pawan May 22 at 6:46
2

Add the Magento crontab

php bin/magento cron:install

Remove the Magento crontab

You should remove the Magento crontab only before uninstalling the Magento application.

bin/magento cron:remove

Run cron from the command line

bin/magento cron:run [--group=""]

For more detail see Magento cron devDocs

I hope it helps!

  • I ran bin/magento cron:run [--group=""] command.. record added into cron_schedule table.. but crons not running automatically.. – Prashant Patil May 22 at 5:55
  • In your cron file add below code to debug log. – Chirag Patel May 22 at 5:58
  • 1
    $writer = new \Zend\Log\Writer\Stream(BP . '/var/log/test.log'); $logger = new \Zend\Log\Logger(); $logger->addWriter($writer); $logger->info('Your text message'); – Chirag Patel May 22 at 5:58
  • On our staging instance, there is read only file system. so I can not copy code directly their. deployment process is very big.. sorry but is there any another way to check on staging instance.. from admin or CLI commands? – Prashant Patil May 22 at 6:02
  • 1
    In cron_schedule table have you checked cron is executed? in execute column? – Chirag Patel May 22 at 6:04
1

Run

php bin/magento cron:install [--force]

Force rewrites existing Magento cron tab

View the crontab by running

crontab -l

Run the crontab by

bin/magento cron:run [--group="<cron group name>"]

Omit the group to run crontab for all groups

You must run cron twice. The first time to discover tasks to run and the second time to run the tasks themselves.

Once done check your cron_schedule table in database to check if cron jobs are scheduled

  • cron:install not working on our staging instance because of read only file system.. it shows error: Error during saving of crontab: You are not allowed to use this program (crontab) – Prashant Patil May 22 at 6:09
  • So the Magento user don't have write access? – Raj Mohan R May 22 at 6:10

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.