Cron 作业的文件路径
您好,我想运行 cron 作业来调用我的服务器上的 PHP 脚本。 我正在从我的网络主机使用 Cpanel,这些是选项:
- 分钟:
- 小时:
- 日
- :月:
- 工作日:
- 命令:
我真的很难将命令指向我的文件我正在使用这一行< code>/home/abbeysof/public_html/adi/cron/daily.php 但我收到此错误:
/bin/sh:/home/abbeysof/public_html/adi/cron/daily.php:权限被拒绝
我向我的网络主机寻求帮助,这是响应:
如果您使用cpanel创建它,它会为您填写路径。通常是/home/username/public_html/etc
任何人都可以提供一些建议吗?
Hi I want to run a cron job to call a PHP script on my server. I am using Cpanel from my web host and these are the options:
- Minute:
- Hour:
- Day:
- Month:
- Weekday:
- Command:
I am really struggling to point the command to my file I am using this line /home/abbeysof/public_html/adi/cron/daily.php
but I am getting this error:
/bin/sh: /home/abbeysof/public_html/adi/cron/daily.php: Permission denied
I asked my web host for help and this is the response:
If you use cpanel to create it, it will fill in the path for you. Typically /home/username/public_html/etc
Can anyone please offer some advice?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
建议1:使用wget命令,wget运行PHP脚本就像从Web调用文件一样,因此PHP环境与从Web调用文件时完全相同,更容易调试那么脚本。
必须在 cPanel cron 作业菜单中创建 cron 作业。我不明白您通过阅读主持人的回答是否清楚了这一点。
建议 2:更改网络托管,尝试这个,他们不会离开你独自的。
Advise 1: use wget command, wget runs the PHP script exactly as if it was called from the web so the PHP environment is exactly the same of when calling the file from the web, it's easier to debug your script then.
The cron jobs has to be created going into cPanel cron jobs menu. I don't understand if you have this clear by reading your hoster's answer.
And advise 2: change web hosting, try this one they don't leave you alone.
抱歉,我对 cpanel 一无所知,但这听起来像:
祝你好运!
Sorry, I don't know anything about cpanel, but it sounds like:
Good luck!
尝试这个
对于某些 cpanels 可能是这样的
try this one
for some cpanels it might be like this
听起来您需要使
/home/abbeysof/public_html/adi/cron/daily.php
可执行。Sounds like you need to make
/home/abbeysof/public_html/adi/cron/daily.php
executable.该链接可能对您有帮助。
https://www.inmotionhosting.com/ support/edu/cpanel/how-to-run-a-cron-job
如果您使用 VPS 与共享主机来发出命令,则会有所不同。
您可能需要使用
user-agent
&cPanel-Cron
以及您的网址。curl --user-agent cPanel-Cron http://example.com/cron.php
The link might help you.
https://www.inmotionhosting.com/support/edu/cpanel/how-to-run-a-cron-job
There is difference if you are using VPS than sharing hosting for giving the command.
You may need to use
user-agent
&cPanel-Cron
along with your url.curl --user-agent cPanel-Cron http://example.com/cron.php