包括路径和cron [英] include path and cron

查看:72
本文介绍了包括路径和cron的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一个调用php脚本的cronjob.当cron调用文件时,出现无法打开流"的消息.当我cd到目录并从该位置运行文件时,一切都很好.基本上,我要包含的include_once()文件是php脚本所在的两个目录.

I'm running a cronjob that calls a php script. I get "failed to open stream" when the file is invoked by cron. When I cd to the directory and run the file from that location, all is well. Basically, the include_once() file that I want to include is two directories up from where the php script resides.

有人可以告诉我如何通过cronjob使它正常工作吗?

Can someone please tell me how I can get this to work from a cronjob?

推荐答案

执行此操作的方法有多种:您可以cd进入cron脚本中的目录:

There are multiple ways to do this: You could cd into the directory in your cron script:

cd /path/to/your/dir && php file.php

或指向相对于PHP中当前脚本的正确包含文件:

Or point to the correct include file relative to the current script in PHP:

include dirname(__FILE__) . '/../../' . 'includedfile.php';

这篇关于包括路径和cron的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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