php - 从 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 测试
解决方案
两种可能的解决方案。
第一个,你可以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
推荐阅读
- django - Ajax request cannot access the URL in Django. I have a problem with an integer( the id)
- bash - how I call the source ~./.bash_profile script from another shell script?
- schema - Challanges in transforming data with tXMLMap Talend
- docker - npm install can't find package.json
- excel - Office JS: Is there a way to find the last row with data in on an excel sheet so that i can then copy that information onto another sheet?
- javascript - Failed to execute 'pushState' on 'History'. Function could not be cloned
- c# - Why is Automapper causing a loading delay in Blazor WebAssembly?
- vue.js - Vue:Vue 路由器没有导航到任何路线
- python - 如何使 python discord bot 执行/使用命令
- jakarta-mail - 带有 OpenJDK 11 的 Jakarta Mail:java.util.ServiceConfigurationError: jakarta.mail.Provider: Provider com.sun.mail.imap.IMAPProvider not a subtype