简体   繁体   English

在cpanel中使用cron作业运行php脚本

[英]Running a php script using cron job in cpanel

I have a php file which runs a script to pull an image from a website and save it in a folder every minute (a webcam if you're interested). 我有一个php文件,该文件运行脚本以从网站提取图像并将其每分钟保存在一个文件夹中(如果您有兴趣,可以使用网络摄像头)。 If I go to the url where the file sits, the page works and the image is saved. 如果我转到文件所在的网址,则该页面可以正常工作并保存图像。 I am trying to set up a cron job in cpanel to do this automatically so I don't have to keep my browser open. 我正在尝试在cpanel中设置一个cron作业以自动执行此操作,因此我不必保持浏览器处于打开状态。 The image below shows my settings but I am getting nothing. 下图显示了我的设置,但是我什么也没得到。 I have set it to send me an email everytime the job runs but I don't get that either. 我已将其设置为在每次作业运行时向我发送电子邮件,但我也没有收到。 I am new to this so any help greatly 我是新手,所以对您有很大帮助 在此处输入图片说明 appreciated. 赞赏。

I can't tell much from the info you gave in , but I have similar type of issue, and what I found out was that I have included .php files in my cron.php and that those links(paths) were not correct for the cron job, but were correct when I opened in browser the php file. 我不能从您提供的信息中得知太多,但是我遇到了类似的问题,并且发现我在cron.php包含了.php文件,并且这些链接(路径)不适合cron作业,但在浏览器中打开php文件时是正确的。

and please check the link in the cpanel the command curl link if it's correct I use something like this 并请检查cpanel中的链接curl链接是否正确我使用了类似的命令

/usr/bin/php /var/www/vhosts/something.com/httpdocs/Cron.php

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

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