13

I am looking for a way to list all magento 2 cron jobs. Is it available somewhere easy to review?

5 Answers 5

17

You can run n98-magerun2 command line utility to list all cronjobs.

If you run the following command in your magento installation, it will display all the cronjobs available in your magento.

n98-magerun2 sys:cron:list

For more detailed tutorial, please visit my medium article.

4
  • 1
    This is what I use, very useful tool!
    – jamil
    Commented Oct 26, 2017 at 18:07
  • 1
    Third party tool but still, I agree that it's very useful. Perfect for development
    – Luke
    Commented Oct 26, 2017 at 19:04
  • should be n98-magerun2.phar sys:cron:list for now.
    – fudu
    Commented Jan 18, 2021 at 9:47
  • This is not working for me.. I am not sure whether this is available at present or not. I have downloaded this plugin but "n98-magerun2 sys:cron:list" command says "bash: n98-magerun2: command not found". Commented Feb 20 at 6:52
10

I decided to get cron jobs list by performing following simple query on a database:

select job_code from cron_schedule GROUP BY job_code;

but it's neither handy nor detailed. Maybe somebody has a better idea...

1

@Luke I needed to review CRON jobs too and I couldn't find any simple solution.

I went the lazy way and used grep to find all <job> entries and put them into one file for easier review:

grep -r -A 2 "<job" . > cron.txt

It's not a great solution, but it may help at this point.

0

You can check following URLs for cron job in Magento 2.

Get cron list from database using following SQL query:

select job_code from cron_schedule GROUP BY job_code;

1
  • 2
    The question is about listing active cron jobs, not running them or creating new ones.
    – Luke
    Commented Oct 17, 2017 at 6:59
0

Inspired by Wojtek Naruniec's answer (https://magento.stackexchange.com/a/198682/104439), but tweaked a bit to skip irrelevant directories, and avoid the redirected file from reading itself;

grep -r -A 2 "<job" app/code/ vendor/ > var/system_cronjobs.txt

Run from the M2 root directory and it will get any system cron jobs that run during cron:run executions. Plus dump to var/ so it works on MCloud as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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