I'm running a cron within the Kohana framework, executing the line
我在Kohana框架内运行一个cron,执行该行
php index.php --uri=nameofcron
where nameofcron is the name of my controller which drives the cron. During this cron's execution, I need to run an exec() statement which executes a java jar executable file. The jar file needs to access resources within a src folder which resides at the same directory level as the jar file. When running this exec() statement within a simple php script in said directory, the exec() runs fine. However when trying to run the exec() statement within my cron's Kohana execution path, it gives me an error saying that resources within the src folder are not found.
其中nameofcron是驱动cron的控制器的名称。在这个cron执行期间,我需要运行一个执行java jar可执行文件的exec()语句。 jar文件需要访问src文件夹中的资源,该文件夹与jar文件位于同一目录级别。在所述目录中的简单php脚本中运行此exec()语句时,exec()运行正常。但是当我尝试在我的cron的Kohana执行路径中运行exec()语句时,它给出了一个错误,指出找不到src文件夹中的资源。
Is there a way to include java resources within the Kohana framework so that I can use them within a cron execution?
有没有办法在Kohana框架中包含java资源,以便我可以在cron执行中使用它们?
1 个解决方案
#1
0
Either you need to change the working directory before running the command (as @hakre said), or you need to include the src folder and the jar itself on the classpath.
您需要在运行命令之前更改工作目录(如@hakre所说),或者您需要在类路径中包含src文件夹和jar本身。
If you want to change the cwd without using the cd
command, I suggest using proc_open
.
如果你想在不使用cd命令的情况下更改cwd,我建议使用proc_open。
To find the path to the jar file programatically I suggest you use Kohana::find_file(...)
.
要以编程方式查找jar文件的路径,我建议您使用Kohana :: find_file(...)。
#1
0
Either you need to change the working directory before running the command (as @hakre said), or you need to include the src folder and the jar itself on the classpath.
您需要在运行命令之前更改工作目录(如@hakre所说),或者您需要在类路径中包含src文件夹和jar本身。
If you want to change the cwd without using the cd
command, I suggest using proc_open
.
如果你想在不使用cd命令的情况下更改cwd,我建议使用proc_open。
To find the path to the jar file programatically I suggest you use Kohana::find_file(...)
.
要以编程方式查找jar文件的路径,我建议您使用Kohana :: find_file(...)。