首页 > 解决方案 > 从 cron 调用 phing 任务

问题描述

我被困了好几天,

我需要一些好方法来从 cron 作业中调用 phing 任务。

实际问题是从cron调用phing任务后,php引擎找不到build.xml文件,该文件位于我项目的主目录中

build.xml 路径:abc/build.xml

phing 路径:abc/vendor/bin/phing

我的 cron : 1 * * * * xyz/local/www/abc/vendor/bin/phing 测试

标签: phpcronphalconphing

解决方案


两种可能的解决方案。

第一个,你可以cd在你的 cron 中使用:

my cron : 1 * * * * cd /xyz/local/www/abc/ && vendor/bin/phing test

第二种解决方案,使用-f选项:

my cron : 1 * * * * /xyz/local/www/abc/vendor/bin/phing -f /path/build.xml test

如果您的构建文件中的相对路径有问题,您还应该在标签中设置basedir属性:<project>

<project default="help" name="my-project" basedir="/xyz/local/www/abc">

资料来源:

https://superuser.com/questions/155576/linux-how-to-run-a-command-in-a-given-directory

https://www.phing.info/phing/guide/en/output/chunkhtml/ch02s03.html

https://www.phing.info/phing/guide/en/output/chunkhtml/ch03s05.html


推荐阅读