本文介绍了Godaddy Cron作业设置,用于运行PHP脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您能帮助我在Godaddy虚拟主机上设置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?

推荐答案

注意::GoDaddy已将所有托管程序包迁移到cPanel.下面的逐项说明适用于旧版GoDaddy界面.命令仍然相同.

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.

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

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

但是我可以使用:wget

我使用wget成功创建了一个cron作业,以加载包含对mail()的调用的PHP文件.

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

  1. 登录您的GoDaddy帐户
  2. 单击以展开虚拟主机"部分并找到有问题的服务器
  3. 点击管理"按钮(以前标记为启动")
  4. 在工具"部分的托管详细信息"页面上,单击"Cron Job Manager"按钮
  5. 在"Cron Job Manager"页面上,单击创建Cron Job"按钮
  6. 输入所需的标题并选择频率(1小时是允许的最频繁的 GoDaddy已为频率选择添加了15分钟的增量.)
  7. 输入以下命令(带有您的信息):
  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 GoDaddy has added 15-minute increments to the frequency choices.)
  7. enter the command below (with your info):

如Leandro所述,

,这是一种使cron作业调用远程或本地资源的方法-如果您仅想在本地调用资源,请查阅GoDaddy文档.如果您正在执行更敏感的工作,则可以更安全)

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)

在"YOUR_PHP_FILE.php"中编写您要执行的所有操作的代码,并包括对mail()的调用(或假设已正确配置,则可能要使用的任何邮件方法).

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).

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

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().

这篇关于Godaddy Cron作业设置,用于运行PHP脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 21:53