3

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

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

3 Answers 3

3

You can use:

php bin/magento cron:install

Above command will Generates and installs crontab for current user

Screen Shot

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

10
  • I ran bin/magento cron:run [--group=""] command.. record added into cron_schedule table.. but crons not running automatically.. May 22, 2019 at 5:55
  • In your cron file add below code to debug log. May 22, 2019 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'); May 22, 2019 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? May 22, 2019 at 6:02
  • 1
    In cron_schedule table have you checked cron is executed? in execute column? May 22, 2019 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

2
  • 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) May 22, 2019 at 6:09
  • So the Magento user don't have write access? May 22, 2019 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.