简体   繁体   English

SSH进入但不是通过cron时,运行PHP文件可以正常工作

[英]Running PHP file works correctly when SSH'd in but not via cron

I am looking to see if a file exists on the server using a php file as per below by running "php check-backup" 我正在通过运行“ php check-backup”来查看服务器上是否存在使用以下php文件的文件:

if (!file_exists("../backups/$today/$hour.sql")) {
    echo "File doesn't exist";
} else {
    echo "File exists";
}

When I run this command on directly on the server when ssh'd in it works perfectly but when this is run as a cron job I cannot get it to find the file. 当我在ssh中直接在服务器上运行此命令时,它可以正常工作,但是当它作为cron作业运行时,我无法获取它来找到文件。

根据Aynber的评论,我检查了使脚本正常工作的完整路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM