Godaddy cron 作业设置用于运行 php 脚本
你能帮我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
注意:GoDaddy 已将所有托管软件包迁移到 cPanel。下面的详细说明适用于旧版 GoDaddy 界面。命令还是一样的。
在撰写本文时,在 GoDaddy 共享主机上,我无法使用以下命令:
ping、curl、nc、lynx
,但我可以使用:
wget
我已成功创建使用
wget
加载包含对mail()
调用的 PHP 文件的 cron 作业。编辑: 正如 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 tomail()
.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 usingphpinfo()
.1:如何知道你的php_path?
2:如何知道文件的绝对路径?
1: How to know your php_path?
2: How to know absolute path of your file?
使用 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
您的 cron 作业命令应如下所示(当然,除非您的目录结构不同):
Regrads、
shahana
Your cron job command should look something like the following (unless your directory structure is different of course):
Regrads,
shahana
如果您使用 Godaddy 这应该可以解决您的问题。
If you are using Godaddy this should solve your issue.
在 Godaddy Linux 托管中。我用这个命令来运行 cron 作业。
In Godaddy Linux hosting. I used this command to run cron job.
例如使用
CURL
或wget
或lynx
。Use, for example
CURL
orwget
orlynx
.参考
Reference
您可以通过托管控制中心设置 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.
如果你想在 Godaddy 中运行 cron 作业。您可以找到以下命令,它一定会对您有所帮助。
If you want to run a cron job in Godaddy. You can find following command, it will surely help you.