Cron 作业的文件路径

发布于 2024-09-07 12:49:59 字数 513 浏览 2 评论 0原文

您好,我想运行 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

只有一腔孤勇 2024-09-14 12:50:00

建议1:使用wget命令,wget运行PHP脚本就像从Web调用文件一样,因此PHP环境与从Web调用文件时完全相同,更容易调试那么脚本。

wget -O - http://yourdomain.com/adi/cron/daily.php >/dev/null 2>&1

必须在 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.

wget -O - http://yourdomain.com/adi/cron/daily.php >/dev/null 2>&1

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.

私藏温柔 2024-09-14 12:50:00

抱歉,我对 cpanel 一无所知,但这听起来像:

  • 如果您创建了 daily.php 文件,那么您需要更改它的权限(
  • 如果他们创建了该文件),那么他们的创建例程中存在错误。

祝你好运!

Sorry, I don't know anything about cpanel, but it sounds like:

  • if you created the file daily.php, then you need to change the permissions on it
  • if they created the file, then there's a bug in their creation routine.

Good luck!

任谁 2024-09-14 12:50:00

尝试这个

/usr/bin/php -q /home/yourCpanelUsername/public_html/filename.php

对于某些 cpanels 可能是这样的

/usr/local/bin/php -q /home/yourCpanelUsername/public_html/filename.php

try this one

/usr/bin/php -q /home/yourCpanelUsername/public_html/filename.php

for some cpanels it might be like this

/usr/local/bin/php -q /home/yourCpanelUsername/public_html/filename.php
じее 2024-09-14 12:50:00

听起来您需要使 /home/abbeysof/public_html/adi/cron/daily.php 可执行。

Sounds like you need to make /home/abbeysof/public_html/adi/cron/daily.php executable.

笑看君怀她人 2024-09-14 12:50:00

该链接可能对您有帮助。
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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文