symfony2中的Cron Job [英] Cron Job in symfony2

查看:305
本文介绍了symfony2中的Cron Job的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目中创建一个控制台命令。我希望它在每天下午7点执行。我该如何在symfony2?一个基本的php cron工作方式或symfony2有更方便的东西?
感谢

I create a console command in my project. I want it to be executed everyday at 7 p.m. How could i do it in symfony2? A basic php cron job way or symfony2 have something more convenient? Thanks

推荐答案

您可以使用基本 cron 。在 debian ubuntu 可以执行此操作:

You can use the basic cron. On debian or ubuntu you can do this:

crontab -e -u <username>

其中 username 是应该执行命令的用户名。
在编辑器中添加命令。这是一个很好的解释行应该如何。对于Symfony2命令,这样的工作应该工作:

Where username is the name of the user that should execute the command. In the editor add your command. Here is a good explanation how the line should look. For a Symfony2 command something like this should work:

* * * * * /usr/bin/php /var/www/symfony2/app/console your:command --option=123

这将执行 your:command --option = 123

机器上,您可以使用 ac 命令。默认情况下,它可用于 Windows 7 在此阅读文档。它应该看起来像这样:

On a windows machine you can use the ac command. It is available for windows 7 by default. Read the docs here. It should look something like this:

AT 00:00 /every:M,T,W,Th,F "php /var/www/symfony2/app/console your:command --option=123"

php 可用的globaly 或<$ c $的路径c> php.exe 文件是正确的。

这篇关于symfony2中的Cron Job的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆