`
shuishui8310
  • 浏览: 155263 次
  • 性别: Icon_minigender_1
  • 来自: 宁波
社区版块
存档分类
最新评论

magento -- 1.4下的计划任务(cron job)

阅读更多

On some points, Magento needs regular maintenance. For instance, when running a shop of which the products are updated frequently, it is needed to refresh catalog indices. Also the search-index might need regular updating. To accomplish these tasks you can run Magento cronjobs. With MagentoTM1.4 this is even easier. Here's how.

Meet cron

Within Linux environments, the program responsible for running scheduled tasks is called cron. Tasks that are run through cron are referred to as cronjobs. By runnning cronjobs daily or perhaps weekly, you can automate certain processes like refreshing the Magento indices or cleaning up logfiles.

Running cronjobs is something that depends on your hosting environment. Almost every Linux-server is shipped with cron-functionality, but within shared hosting environments it just depends whether you are allowed to use or not. Popular control panels like DirectAdmin or CPanel often allow you to create new cronjobs.

Running a Magento 1.4 job through cron

With Magento 1.3 and older, you had to write your own PHP-scripts to get things done. With Magento 1.4 this has become much easier. Within the Magento directory "shell" you can find various PHP-scripts that automate certain actions. The rest of this tutorial will discuss those actions as well.

Running such a script through cron doesn't mean calling this script through the browser. You'll need command-line access to your Magento site to run such a script manually. In exactly the same way that you run this from the command-line, the cronjob is also run. In the following examples, you will need to replace "/path/to/magento" with the exact directory that contains Magento.

This will reindex all the Magento indices. Now this command first calls the PHP-program "php" with as first argument the location of the PHP-script, and as second argument something that is used as argument for the script.

It might be that the "php" program is not found by cron, in which case you will need to define the exact path to the "php" binary program:

To surpress output from the Magento script you can also add the flag "-q" (quiet):

If you're running against memory limits, you might try to skip the regular configuration by using the flag "-n":

The main cronjob

While this tutorial mainly deals with indexing and caching, there is another cronjob which should be seen as the primary cronjob: It is contained in the file "cron.php" and every Magento module that wants to schedule a certain job through Magento is handled through it. The only thing you need to do is run the script (without any arguments), let's say every night:

More Magento reindexing

When running the indexer.php script from the command-line we can find more tricks. First of all we can check for the current status of all the indices:

We can also refresh a specific index. To do so, we first need to find out which arguments can be used:

This gives a listing like the following:

Now we found the technical names for the various indices, which we can use like the following example:

The last example is again something we can use through cron.

Clean logs and using the Magento compiler

Besides refreshing indices, we can also clean up all the logs within the database:

Even cooler is the new Magento Compiler module which is still in beta but gives great performance benefit by reducing the number of include-paths (4 by default) to one single include-path. This mainly saves CPU-resources.

You can check for the current state of the compiler by running the following:

Once checked you can disable the compiler temporarily, rebuild the include-paths again with the flag "compile" and enable the compiler once more.

原文链接地址:http://www.yireo.com/tutorials/magento/magento-administration/340-magento-14-cronjobs

PS: 关于cronjobs我已经在置顶的文章里描述过,内容是基于Magento1.3的 http://blog.csdn.net/shuishui8310/archive/2010/05/08/5570926.aspx

这篇文章描述的是Magento1.4环境下cronjobs的变化和设置方法的不同之处

分享到:
评论

相关推荐

    Magento-中文开发教程

    Magento-中文开发教程, 欢迎大家指出错误。 深入理解Magento-第一章 – Magento强大的配置系统 深入理解Magento-第二章 – Magento请求分发与控制器 深入理解Magento-第三章 – 布局,块和模板 深入理解...

    magento-ce-2.4.0_sample_data-2020-07-26-02-51-57.tar.gz

    magento-ce-2.4.0_sample_data-2020-07-26-02-51-57.tar.gz Include sample data

    magento-ce-2.4.0-2020-07-24-11-15-38.tar.gz

    magento-ce-2.4.0-2020-07-24-11-15-38.tar.gz 不带sample data

    Magento-Redismanager, 在 Magento,用于Redis的超级用户控制.zip

    Magento-Redismanager, 在 Magento,用于Redis的超级用户控制 Redis 管理Redis服务的实用程序特性系统> 配置>的自动或者手动配置高级> Redis管理在负载均衡环境中缓存服务不同的理想情况直接从magento面板管理员管理...

    Magento-中文开发教程.doc

    理解Magento的目录结构和模板层次关系是关键,例如,`app/design/frontend`目录下存储了前端主题文件。 四、Magento的模块开发 Magento的核心功能由一系列模块组成,开发者可以通过编写自己的模块来扩展或替换原有...

    magento1.4.1.1

    Magento 1.4.1.1 是一个深受商家喜爱的开源电子商务平台,它以其强大的功能、高度可定制性和模块化的架构赢得了业界的认可。这个版本在2008年发布,是Magento系列的一个重要里程碑,为中小企业提供了搭建在线商店的...

    magento-1.8.0.0.tar.gz

    2. **多店支持**:Magento 1.8.0.0 支持多店铺管理,用户可以在同一个后台管理系统下运营多个不同主题的商店。 3. **强大的商品管理**:提供了详细的商品分类、属性和选项设置,支持多种促销规则,如优惠券、折扣、...

    magento-transporter-cron

    `magento-transporter-cron-master` 这个压缩包可能包含了一个 Magento Transporter Cron 的源代码仓库主分支,用于帮助用户理解和定制自己的 Cron 任务。以下将详细介绍 Magento Transporter Cron 及其相关知识点:...

    Magento-SMTP-Email

    "Magento-SMTP-Pro-Email-Extension"是一个专业的SMTP扩展,提供了一系列高级功能。以下是该插件的一些核心特性: 1. **多SMTP配置**:商家可以根据不同的业务需求配置多个SMTP服务器,比如用于测试和正式环境。 2...

    magento-java-master.zip_magento

    这个“magento-java-master.zip_magento”压缩包可能是为了提供一个Java连接Magento源码的示例或者库,帮助开发者实现Java与Magento系统的交互。 在Java中与Magento进行交互通常涉及到以下几个关键知识点: 1. **...

    magento -redis 插件安装包

    - 队列服务:在Magento中,Redis也可用于消息队列,处理异步任务,如订单处理、发送邮件等。 2. **Magento与Redis集成的意义**: - 性能优化:通过Redis的内存存储,提高数据读取速度,改善用户购物体验。 - ...

    magento-ce-2.4.2-p1-2021-04-22-10-49-09.zip

    因为国外网速太慢了,所以下载后分享给需要的人。magento-ce-2.4.2-p1-2021-04-22-10-49-09

    magento-演示数据1.6.1.0

    "magento-演示数据1.6.1.0"是一个专门为Magento 1.6.1.0版本准备的示例数据包,它包含了用于演示和测试 Magento 商店功能的各种数据,如产品、类别、顾客、订单等。 该压缩包文件“magento-sample-data-1.6.1.0”...

    PyPI 官网下载 | magento-0.6dev.tar.gz

    标题中的"PyPI 官网下载 | magento-0.6dev.tar.gz"指的是Python Package Index(PyPI)上的一个项目,它是一个名为"Magento"的软件包的特定版本,即0.6dev。PyPI是Python开发者发布和分享他们自己创建的Python库或...

    magento-coding-standard:Magento编码标准

    在Magento 2站点内安装要在您的Magento 2项目中使用,可以使用: composer require --dev magento/magento-coding-standard 出于安全考虑,以这种方式安装时,无法自动添加phpcs的Magento标准。 您可以通过将以下...

    magento-1.7.0.2汉化包|magento-1.7.0.2中文语言包下载

    标题提到的是"magento-1.7.0.2汉化包",这表明我们讨论的是Magento 1.7.0.2版本的中文语言包。这个版本是Magento在2012年发布的一个稳定版本,对于中国市场来说,汉化包的提供极大地提高了中国用户使用该平台的便利...

    Magento-CE-2.3.4_sample_data-2020-01-22-11-11-58.tar.gz

    Magento-CE-2.3.4_sample_data-2020-01-22-11-11-58.tar.gz源自官网

    Ajax-Magento-ajax-add-to-cart.zip

    Ajax-Magento-ajax-add-to-cart.zip,[模块magento 1]magento ajax添加到购物车-ajoter vos produits au panier en ajax/感谢ajax将您的产品添加到购物车,ajax代表异步javascript和xml。它是多种web技术的集合,包括...

    Magento-Vagrant-Puppet-Nginx:安装magento和Nginx服务器

    Magento-Vagrant-Puppet-Nginx 安装次数 Magento MySQL PHP PHP-FPM Nginx的 n98-玛格伦 设置 git submodule init git submodule update vagrant up 修改人偶/清单/base.pp class { "magento" : install_...

    magento-stock-movements, Magento扩展,节省产品库存.zip

    magento-stock-movements, Magento扩展,节省产品库存 节省你的Magento产品的库存 特性将库存移动保存在产品修改页面的新标签中安装 Magento 1.5. x, 1.6. x, 1.7. x, 1.8. x, 1.9.x使用 modgit 安装:$ cd/pat

Global site tag (gtag.js) - Google Analytics