How would test cron with Magento?

后端 未结 5 606
有刺的猬
有刺的猬 2021-01-30 18:29

First I need to understand how Magento cron works.

I know how cron works on linux, using crontab -e.
I know I need to set up Magento\'s cron.php to run

5条回答
  •  孤独总比滥情好
    2021-01-30 19:02

    On the second half of your question... how to tell if its running.

    Here is something that I did. I added the following code at the end of the cron.php file. This updates a simple log called "cronlog.txt" everytime the cron.php file gets called.

    So, if I have doubts about cron running I can just glance at that file and see the last date and time the cron.php file ran.

    try {
       $myFile = "cronlog.txt";
       $fh = fopen($myFile, 'w');
       $stringData = date('l jS \of F Y h:i:s A');
       fwrite($fh, $stringData);
       fclose($fh);
    } catch (Exception $e) {
       Mage::printException($e);
    }
    

提交回复
热议问题