2

having a module that just run through cron, can I test it without firing the cron process? I installed AOE scheduler but even if I select the process and run it, I've to wait for the cron scheduling.

Is there any solution to run it like calling an url, bypassing the cron process?

thanks very much

| improve this question | | | | |
3

The best way to test cron methods in any new controller action. There is no difference between method, which executes by cron and any other observer method.

You can create your own controller (or use any existing controller and temporarily call there this action).

Following solution is not very clean. Purpose of this solution only understand what do you need:

For example there is ProductController.

app/code/core/Mage/Catalog/controllers/ProductController.php

This controller has many different actions, like viewAction, etc... You can create any new action like cronAction and put there your call there:

Mage::getModel('yourmodulename/observer')->yourCronMethod();

Don't forget to write your existed module, class and method names. After that call in browser

http://host/catalog/product/cron

| improve this answer | | | | |
2

I would suggest checking out Magerun https://github.com/netz98/n98-magerun

Really simple to get installed and set up.

You can run cron jobs direct from CLI, have a read of the git page theres loads of tasks that will save you a shed load of time.

Runninf a cron job is as simple as

n98-magerun.phar sys:cron:run [job]

You can also see all cron jobs by running

n98-magerun.phar sys:cron:list

| improve this answer | | | | |
1

To test a cron manually, set up crontab in your config.xml every minute like this

<crontab>
    <jobs>
        <mysample_cron_auto>
            <schedule>
                <cron_expr>* * * * *</cron_expr>
            </schedule>
            <run>
                <model>namespace_module/observer::methodName</model>
            </run>
        </mysample_cron_auto>
    </jobs>
</crontab>

To now test this cron, you can go to your browser and run www.yourMagentoPath/cron.php.

You can die here and check the execution of the observer method.

P.S. Make sure you do not have any other cron that runs every minute, otherwise there are chances of conflict.

EDITED

To by pass the cron process,

Create a file test.php inside your magento root folder and write the code in that file and then execute it with below URL http://www.yourdomain.com/test.php

| improve this answer | | | | |
  • I think is the same to run it through AOE schedule, what i'd to do is to bypass cron process. thanks – Antonio Pedicini Aug 14 '15 at 10:35
  • Check my updated answer – Manashvi Birla Aug 14 '15 at 10:52
  • can't, as is a really complex module, not just one file. I guess I've to create a controller to initialize the module and bypass the cron process – Antonio Pedicini Aug 14 '15 at 11:16

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.