php 如何通过Cpanel每天6点进行cron工作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12402352/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 03:29:25  来源:igfitidea点击:

how to make cron job every day at 6 O'clock by Cpanel

phpcron

提问by samino sami

how to make cron job every day at 6 O'clock by Cpanel ? I added cron job by my cpanel as this picture

如何通过Cpanel每天6点进行cron工作?我通过我的 cpanel 添加了 cron 作业作为这张图片

http://i.imgur.com/vc1iv.jpg

http://i.imgur.com/vc1iv.jpg

But the script work more one time in the day , I need to know the error in cron or in my script .

但是该脚本一天中工作更多,我需要知道 cron 或我的脚本中的错误。

回答by Mihai Iorga

Your cron will run every minute at 6 o'clock, because of that asterisk.

由于那个星号,您的 cron 将在 6 点钟每分钟运行一次。

Cron format:

定时格式

* * * * * *
| | | | | | 
| | | | | +-- Year              (range: 1900-3000)
| | | | +---- Day of the Week   (range: 1-7, 1 standing for Monday)
| | | +------ Month of the Year (range: 1-12)
| | +-------- Day of the Month  (range: 1-31)
| +---------- Hour              (range: 0-23)
+------------ Minute            (range: 0-59)
Any of these 6 fields may be an asterisk (*). 
This would mean the entire range of possible values, i.e. each minute, each hour, etc.

You should put minute 0 because you need to run it just once (at 06:00).

你应该把分钟 0 因为你只需要运行一次(在 06:00)。

0 6 * * * 

回答by Zagorax

You should change your cronjob like following:

您应该像下面这样更改您的 cronjob:

0 6 * * * /usr/bin/php and so on

0 6 * * * /usr/bin/php and so on

In this way it will run at 6 o'clock. In your way, it will start running at 6 and then it will run again every minute for an hour.

这样它就会在 6 点钟运行。按照您的方式,它将从 6 点开始运行,然后每分钟再次运行一个小时。

As example, if you want a script to run on the 3rd day of the month at midnight, you should write:

例如,如果您希望脚本在每月第 3 天的午夜运行,您应该编写:

0 0 3 * * /usr/bin/php and so on

0 0 3 * * /usr/bin/php and so on

If you leave asterisk on the first two field, it will run for the whole day.

如果在前两个字段上留下星号,它将运行一整天。

Have a look to the man page. Some example can be very useful, i.e. the one with @dailymacro.

查看手册页。一些示例可能非常有用,即带有@daily宏的示例。