Godaddy cron 作业设置用于运行 php 脚本

发布于 2024-12-09 01:21:43 字数 197 浏览 0 评论 0原文

你能帮我在 godaddy webhosting 上设置 cron 作业吗?我有需要运行的 php 文件,它位于 cron 子目录中(所以地址是 http://test .com/cron/file.php)。 我需要在命令输入字段中写入什么才能运行该文件?

can you help me setup cron job on godaddy webhosting? I have php file that i need to run, it is located in cron subdirectory (so address is http://test.com/cron/file.php).
What do i need to write in command input field, so this file is runned?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(10

拥抱影子 2024-12-16 01:21:43

注意:GoDaddy 已将所有托管软件包迁移到 cPanel。下面的详细说明适用于旧版 GoDaddy 界面。命令还是一样的。

在撰写本文时,在 GoDaddy 共享主机上,我无法使用以下命令:ping、curl、nc、lynx

但我可以使用:wget

我已成功创建使用 wget 加载包含对 mail() 调用的 PHP 文件的 cron 作业。

  1. 登录您的 GoDaddy 帐户
  2. 单击展开“虚拟主机”部分并找到有问题的服务器
  3. “管理”按钮(以前标记为“启动”)
  4. 单击“工具”部分的“托管详细信息”页面上的 按钮
  5. ,单击“Cron Job Manager”页面上的“Cron Job Manager”
  6. ,点击“创建 Cron Job”按钮输入您想要的标题并选择频率(1 小时是允许的最频繁编辑: GoDaddy 有额外频率选择以 15 分钟为增量。)
  7. 输入以下命令(包含您的信息):

wget http://YOUR_DOMAIN/YOUR_PATH/YOUR_PHP_FILE.php > /dev/null 2>&1

编辑: 正如 Leandro 所指出的,这是使 cron 作业调用远程或本地资源的方法 - 如果需要,请参阅 GoDaddy 文档仅在本地调用资源(如果您运行更敏感的作业,这也更安全),

在“YOUR_PHP_FILE.php”中编写您想要执行的所有操作,并包括对 mail()(或任何邮寄方式假设您已正确配置,您可能需要使用)。

通过使用 mail(),SMTP 中继服务器已在“php.ini”文件中正确设置为:relay-hosting.secureserver.net——您可以使用 phpinfo() 确认。

NOTE: GoDaddy has been migrating all hosting packages over to cPanel. The itemized instructions below are for the older GoDaddy interface. The command is still the same.

At the time of this writing, on GoDaddy shared hosting, i could NOT use the following commands: ping, curl, nc, lynx

but i COULD use: wget

I successfully created a cron job using wget to load a PHP file containing a call to mail().

  1. log into your GoDaddy account
  2. click to expand the "Web Hosting" section and find the server in question
  3. click the "Manage" button (it used to be labeled "Launch")
  4. on the "Hosting Details" page in "Tools" section, click "Cron Job Manager" button
  5. on the "Cron Job Manager" page, click "Create Cron Job" button
  6. enter the title you want and select the frequency (1 hour is the most frequent allowed EDIT: GoDaddy has added 15-minute increments to the frequency choices.)
  7. enter the command below (with your info):

wget http://YOUR_DOMAIN/YOUR_PATH/YOUR_PHP_FILE.php > /dev/null 2>&1

edit: as noted by Leandro, this is the method to make a cron job call a remote or local resource -- consult GoDaddy documentation if you want to call a resource locally only (which is also more secure if you're running more sensitive jobs)

in "YOUR_PHP_FILE.php" code all the actions you want to be performed and include a call to mail() (or whichever mail method you may want to use assuming you have configured that properly).

By using mail() the SMTP relay server will already be set properly in the "php.ini" file to: relay-hosting.secureserver.net -- which you can confirm using phpinfo().

数理化全能战士 2024-12-16 01:21:43
php_path -q file_name_with_absolute_path

/usr/bin/php -q /home/[user name]/public_html/test.php

1:如何知道你的php_path?

echo exec('whereis php');

2:如何知道文件的绝对路径?

echo dirname(__FILE__);
php_path -q file_name_with_absolute_path

/usr/bin/php -q /home/[user name]/public_html/test.php

1: How to know your php_path?

echo exec('whereis php');

2: How to know absolute path of your file?

echo dirname(__FILE__);
凉薄对峙 2024-12-16 01:21:43

使用 Cpanel 为 GoDaddy 共享主机帐户设置 Cron。

*-->>Cron 作业在 GoDaddy 位于亚利桑那州的时区运行。 GoDaddy 不会在任何地方发布此内容。

例子:
每天在太平洋标准时间 1305(下午 1:05)运行 cron。

5 14 * * * /usr/local/bin/php -q /home/用户名/public_html/scriptname.php

Cron Setup for GoDaddy Shared Hosting Accounts using Cpanel.

*-->>Cron jobs run on GoDaddy's time zone in Arizona. Go Daddy doesn't publish this anywhere.

Example:
Run cron everyday at 1305 (1:05pm) pacific standard time.

5 14 * * * /usr/local/bin/php -q /home/username/public_html/scriptname.php

日暮斜阳 2024-12-16 01:21:43

您的 cron 作业命令应如下所示(当然,除非您的目录结构不同):

/web/cgi-bin/php5 "$HOME/html/sendy/scheduled.php" > /dev/null 2>&1

Regrads、

shahana

Your cron job command should look something like the following (unless your directory structure is different of course):

/web/cgi-bin/php5 "$HOME/html/sendy/scheduled.php" > /dev/null 2>&1

Regrads,

shahana

二智少女 2024-12-16 01:21:43

如果您使用 Godaddy 这应该可以解决您的问题。

 *  *   *   *   *   /usr/local/bin/php /home/path/to/your/file.php > /dev/null

If you are using Godaddy this should solve your issue.

 *  *   *   *   *   /usr/local/bin/php /home/path/to/your/file.php > /dev/null
神经暖 2024-12-16 01:21:43

在 Godaddy Linux 托管中。我用这个命令来运行 cron 作业。

/usr/bin/php public_html/now your path

In Godaddy Linux hosting. I used this command to run cron job.

/usr/bin/php public_html/now your path
↙厌世 2024-12-16 01:21:43

例如使用 CURLwgetlynx

lynx -s http://link.to/script.php

Use, for example CURL or wget or lynx.

lynx -s http://link.to/script.php
双马尾 2024-12-16 01:21:43
/usr/local/bin/php -q /home/[user name]/[path to the file]

参考

/usr/local/bin/php -q /home/[user name]/[path to the file]

Reference

痴情 2024-12-16 01:21:43

您可以通过托管控制中心设置 cron 作业。请在此处查看 GoDaddy 的官方页面:https://www.godaddy.com/help/ create-cron-jobs-3548 了解如何设置它。

You can setup cron jobs through the Hosting Control Center. Check out GoDaddy's official page here: https://www.godaddy.com/help/create-cron-jobs-3548 for a how-to on setting it up.

友欢 2024-12-16 01:21:43

如果你想在 Godaddy 中运行 cron 作业。您可以找到以下命令,它一定会对您有所帮助。

php -f /home/[user name]/[path to the file] 

If you want to run a cron job in Godaddy. You can find following command, it will surely help you.

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