简体   繁体   English

如何在cpanel中配置cron作业

[英]How to configuration cron job in cpanel

How to configuration Cron Job in cPanel for .PHP script. 如何在cPanel中为.PHP脚本配置Cron Job。

I want to run it every day once a day. 我想每天运行一次。

Where i need to store this .php file ? 我需要在哪里存储此.php文件?

How can i check whether its working or not ? 我如何检查其是否正常工作?

You can do it through command but since you using cPanel, use the interface: 您可以通过命令来完成,但是由于您使用的是cPanel,因此请使用以下接口:

在此处输入图片说明

Then fill out Add New Cron Job 然后填写添加新的Cron作业

在此处输入图片说明

For example, a cron for a php script that runs everyday at midnight sharp would look like this 例如,每天下午12点运行的php脚本的cron看起来像这样

Minute  Hour    Day   Month    Weekday  

0        0        *     *         *     php /path/to/script.php
  1. Click on the "Cron Jobs" icon inside cPanel, under Advanced. 单击cPanel中“高级”下的“克隆作业”图标。
  2. Make sure the current email address is valid. 确保当前的电子邮件地址有效。 If not, enter a new email and click the "Update Email" button. 如果没有,请输入新电子邮件,然后单击“更新电子邮件”按钮。
  3. Select the Common Setting you want. 选择所需的通用设置。 This will automatically change the other time settings. 这将自动更改其他时间设置。
  4. Alternatively, you may adjust the individual time settings. 或者,您可以调整各个时间设置。 Minute, Hour, Day, Month and Weekday can be modified to achieve your goal. 可以修改分钟,小时,天,月和周日以实现您的目标。
  5. In the input box to the right of "Command", type the name of the file type, then add a space and provide the path to the file which you would like the command to run. 在“命令”右侧的输入框中,键入文件类型的名称,然后添加一个空格并提供您要运行命令的文件的路径。

Click the "Add New Cron Job" button. 单击“添加新的Cron作业”按钮。

Link : 连结:

Here Link 这里链接

You may put the file.php file in the "public_html" folder in your server. 您可以将file.php文件放在服务器的“ public_html”文件夹中。 You have the option of cron job in the cpanel "Advanced" section. 您可以在“高级”面板中选择cron作业。 Once you're there you have the option to add a new cron job and "common setting" called "Once a day", which will satisfy your need. 在那里,您可以选择添加新的cron作业和称为“每天一次”的“通用设置”,这将满足您的需求。 In the "command" field paste this: wget --spider http://yoursite.com/file.php and then save. 在“命令”字段中粘贴以下内容: wget --spider http://yoursite.com/file.php ,然后保存。

Of course this is not the best practice, but I hope it will do the job for you. 当然,这不是最佳做法,但我希望它能为您完成这项工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM