Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当通过cron运行时,php exec tar调用失败,通过shell运行_Php_Exec_Tar - Fatal编程技术网

当通过cron运行时,php exec tar调用失败,通过shell运行

当通过cron运行时,php exec tar调用失败,通过shell运行,php,exec,tar,Php,Exec,Tar,有人能解释为什么这一行在从shell调用时工作,但在通过crontab调用时失败吗 passthru("tar xvf $file $tarfile/application $tarfile/application_detail $tarfile/application_device_type $tarfile/genre_application"); } cron被删除后我收到的电子邮件错误 tar:itunes20100907/应用程序: 无法打开:没有这样的文件或目录 itunes201

有人能解释为什么这一行在从shell调用时工作,但在通过crontab调用时失败吗

passthru("tar xvf $file $tarfile/application $tarfile/application_detail $tarfile/application_device_type $tarfile/genre_application");
}
cron被删除后我收到的电子邮件错误

tar:itunes20100907/应用程序: 无法打开:没有这样的文件或目录 itunes20100907/应用程序详细信息


正如错误所说,您一定是在错误的目录中。您应该使用规范路径


注意:启用时,您只能在中执行文件。出于实际原因,目前不允许有。。可执行文件路径中的组件


您可以使用PHP中的
getcwd()
函数来找出脚本运行的路径。对于cron作业,它可能是cron用户的主文件夹。如果是/home/ubuntu/,那么路径itunes20100907/application将被解释为/home/ubuntu/itunes20100907/application