course/process/Task.php
2024-08-04 22:28:52 +08:00

43 lines
980 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace process;
use Workerman\Crontab\Crontab;
class Task
{
public function onWorkerStart()
{
// 每秒钟执行一次
new Crontab('*/1 * * * * *', function(){
echo date('Y-m-d H:i:s')."\n";
});
// 每5秒执行一次
new Crontab('*/5 * * * * *', function(){
echo date('Y-m-d H:i:s')."\n";
});
// 每分钟执行一次
new Crontab('0 */1 * * * *', function(){
echo date('Y-m-d H:i:s')."\n";
});
// 每5分钟执行一次
new Crontab('0 */5 * * * *', function(){
echo date('Y-m-d H:i:s')."\n";
});
// 每分钟的第一秒执行
new Crontab('1 * * * * *', function(){
echo date('Y-m-d H:i:s')."\n";
});
// 每天的7点50执行注意这里省略了秒位
new Crontab('50 7 * * *', function(){
echo date('Y-m-d H:i:s')."\n";
});
}
}