4

I want realise a cron job for import product in Magento. The code to insert the product into a php file saved in app/code/local/Test/Import/Model.

I saved config.xml in app/code/local/Test/Import/etc. I added module in app/etc/modules.

config.php contains following code:

<config>
     <modules>
        <Test_Import>
            <version>0.0.1</version>
        </Test_Import>
    </modules>
    <frontend>
        <routers>
            <import>
                <use>standard</use>
                <args>
                    <module>Test_Import</module> 
                    <frontName>import</frontName> 
                </args>
            </import>
        </routers>
    </frontend>
    <global>
        <models>
            <import>
                <class>Test_Import_Model</class>
            </import>
        </models>
    </global> 
    <crontab>
        <jobs>
            <import>
                <schedule>
                    <cron_expr>*/1 * * * *</cron_expr>
                </schedule>
                <run>
                    <model>import/observer::importProduct</model>
                </run>
            </import>
        </jobs>
    </crontab>
</config>

When I try to run it the result is 404 PAGE NOT FOUND.

Which is the correct url to run the cron?

1

4 Answers 4

6

The cron jobs in Magento don't have an URL to run with. To test it you have to wait the time you defined and ensure it is running.

Installing the module AOE_Scheduler can help you handling and debug them.

If you have the suspect your cron jobs are not executed, you can call manually the example.com/cron.php URL from the browser. But since the SUPEE-6788 security patch, this is forbidden by default and you have to add permissions in .htaccess first. See: After applying SUPEE-6788 , cron stopped working

It's better to run

php /path/to/magento/cron.php -mdefault

on the command line

2
  • 1
    I installed Magento on Windows 7. Where is the file .htaccess? How can I change permissions? Many thanks!!
    – Federica
    Commented Aug 28, 2016 at 14:48
  • 1
    The .htaccess file is located in the Magento root folder. However, it might be recognised as a hidden file and not shown in the file explorer. Try to open it via terminal (command line) or enable the visualisation of hidden files in Windows explorer. Commented Aug 28, 2016 at 16:36
4

Be sure to add Magento cron.sh file in crontab

crontab -e

*/5 * * * * /bin/sh /path-to-magento/cron.sh
0

Go to server and setup your cronjob and cron.sh file in your severs cronjob

Then this all cronjobs that you define in crontab is working fine .

For how to add cron.sh file you can follow this post.

Which cron script is best to run? cron.php or cron.sh

0

ADDING A NEW MAGENTO CRON TASK VIA CPANEL

To set up a new cron task in Magento via cPanel, log into your site’s configuration panel at

http://yourmagentosite.com:2082/ or https://yourmagentosite.com:2083/.

Then, enter cron into the search field, and you’ll see a Cron jobs option in the Advanced section.

setup cron magento

To set up a cron job with this method, you may need to enter an email address in the Cron email section. This email will be used to send cron messages to, which is useful in case of any cron job execution issues.

setup cron magento

Now let’s set the cron schedule and the command to be run.

setup cron magento

Press Add New Cron Job to finish your configuration.

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.