How to setup a CRON JOB in MAGENTO?

2019-08-16 07:07发布

问题:

I want to setup a CRON JOB in Magento. My requiremen-: In our shop which is built in Magento, Customers,products & tier prices are coming in .csv file which we manually importing till the time.

So now we are reading that .csv file which is where Magento is placed through PHP. We fetch that data in csv file through php & insert data in relevant tables of Magento database.

So for that I made php file which externally connected to Magento db & do the needful task of fetching & inserting data. Now how to setup CRON job so that this process will become automatic...I gone through Magento website where they mention How to setup a cron job?

http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/how_to_setup_a_cron_job

but still have a plenty of doubts... So can anybody explain me how should I set up cron job so that this sample php file work & our process of fetching & inserting Customer, products, Pricing etc. become automatic?

Plz provide me basic info. on how to setup cron job in Magento for above scenario or can we use CRON job created with the help of PHP?

http://net.tutsplus.com/tutorials/php/managing-cron-jobs-with-php-2/

If anyone have sample code for the same that will really help me alot...

plz guide me.

回答1:

it's nothing specify related to Magento, which is just another php script. just set up the cron to run the appropriate script from the command line

php /path to script/script.php



回答2:

Setting a cron in magento can be done by opening the cron tab for editing and then specifying the path :-

*/10 * * * * php -q /path/to/magento/cron.php

It will run your cron every 10 minutes.

You can check the magento admin as well and change the required thing like log clearing and all.

System > Configuration > Advanced > System > Cron (Scheduled Tasks)



回答3:

If you are comfortable making HTTP requests from your PHP scripts on the server, SaturnAPI has a secure scheduling solution that may be suitable for you. It's a REST API. You make HTTP requests to schedule, view and delete jobs. Below is an example for scheduling a job:

curl -X POST \
  https://saturnapi.com/cron/jobs \
    -H saturnapi-access-key:'YOUR_SATURNAPI_ACCESS_KEY' \ 
    -d dateTimeUTC='2015:09:25 14:30' \
    -d dateTimeFormat='YYYY:MM:DD HH:mm' \
    -d callbackURL='https://your.verified.domain.com' \

When the time comes, the callbackURL will receive an HTTP POST. It's very simple, and there's no need to install anything on your server.

Disclosure: I worked on SaturnAPI