×ðÁú¿­Ê±

ÔõÑùʹÓÃThinkPHP6¾ÙÐÐͼÐλ¯µÄʹÃüµ÷ÀíÖÎÀí£¿

ÔÚʹÓÃphp¾ÙÐÐÓªÒµ¿ª·¢µÄÀú³ÌÖУ¬ÎÒÃǾ­³£ÐèҪ׼ʱִÐÐһЩʹÃü£¬ºÃ±È׼ʱÌìÉú±¨±í¡¢×¼Ê±·¢ËÍÓʼþ¡¢×¼Ê±±¸·ÝÊý¾ÝµÈµÈ¡£´Ëʱ£¬Ê¹Ãüµ÷ÀíÖÎÀí¾Í³ÉΪÁËÎÒÃDz»¿É»òȱµÄÒ»²¿·Ö¡£ÔÚÓªÒµ²ãÉè¼ÆÖ®³õ¾Í˼Á¿ºÃʹÃüµ÷ÀíÖÎÀíµÄÎÊÌ⣬Äܹ»Ìá¸ß×ðÁú¿­Ê±¿ª·¢Ð§ÂʺʹúÂëµÄ¿ÉÀ©Õ¹ÐÔ¡£±¾ÎÄÖ¼ÔÚÏÈÈÝÔõÑùʹÓÃthinkphp6¾ÙÐÐͼÐλ¯µÄʹÃüµ÷ÀíÖÎÀí¡£

Ò»¡¢Ê¹Ãüµ÷Àí¿â

ÔÚʹÓÃThinkPHP6¾ÙÐÐʹÃüµ÷ÀíÖÎÀí֮ǰ£¬ÐèÒªÏÈ×°ÖÃÏìÓ¦µÄ¿â¡£ThinkPHP6ÌṩÁËÒ»¸öÃûΪthink-schedule£¨Ò»¿îÇáÁ¿¼¶µÄʱÐòµ÷Àí×é¼þ£©µÄ¿â£¬Í¨¹ýËü¿ÉÒÔ×ÊÖúÎÒÃÇ¿ìËÙµØÍê³ÉʹÃüµ÷ÀíÖÎÀí¡£ÔÚ×°Öøÿâ֮ǰ£¬ÐèҪȷ±£±¾»úÒѾ­×°ÖÃÁËComposer£¬ÈôÊÇûÓÐ×°Öã¬ÇëÏÈ×°ÖÃComposer¡£

ʹÓÃÒÔÏÂÏÂÁî×°ÖÃthink-schedule£º composer require topthink/think-schedule

×°ÖÃÀÖ³ÉÖ®ºó£¬»áÔÚÏîÄ¿µÄcomposer.jsonÎļþÖп´µ½Ïà¹ØµÄÒÀÀµÐÅÏ¢£¬²¢ÔÚvendorĿ¼ÌìÉúÏà¹ØµÄÎļþ¡£

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡± £»

¶þ¡¢ÔõÑù½ç˵ʹÃü

ÔÚ×îÏÈʹÓÃThinkPHP6¾ÙÐÐͼÐλ¯µÄʹÃüµ÷ÀíÖÎÀí֮ǰ£¬ÎÒÃÇÐèÒªÏȽç˵ºÃÒªµ÷ÀíµÄʹÃüÀࡣʹÃüÀà±ØÐè¼ÌÐø×ÔthinkscheduleTaskÀ࣬²¢ÊµÏÖrunÒªÁ죬¸ÃÒªÁìΪÎÒÃǽç˵¸ÃʹÃüÖ´ÐеÄÏêϸÂß¼­¡£

ÀýÈ磺

<?php
namespace app    ask;

use thinkscheduleTask;

class Test extends Task
{
    protected function configure()
    {
        // ¸ÃʹÃüµÄÉèÖÃÐÅÏ¢
        $this->setName('test')->setDescription('²âÊÔʹÃü');
    }

    protected function execute(    hinkConsole $console)
    {
        // ¸ÃʹÃüµÄÖ´ÐÐÂß¼­
        echo '²âÊÔʹÃüÖ´ÐÐÀÖ³É';
    }
}

µÇ¼ºó¸´ÖÆ

ÔÚ¸ÃʾÀýÖУ¬ÎÒÃǽç˵ÁËÒ»¸öÃûΪTestµÄʹÃüÀà¡£ÔÚÀàµÄconfigureÒªÁìÖУ¬ÎÒÃÇ¿ÉÒÔÉèÖøÃʹÃüµÄÏà¹ØÐÅÏ¢ £»ÔÚexecuteÒªÁìÖУ¬ÔòÊÇÏêϸµÄʹÃüÂß¼­¡£Ò²¾ÍÊÇ˵£¬ÎÒÃÇ¿ÉÒÔÔÚconfigureÒªÁìÖнç˵ʹÃüµÄ»ù±¾ÐÅÏ¢£¨ÀýÈçʹÃüµÄÃû³Æ¡¢Ê¹ÃüµÄÐÎòµÈµÈ£©£¬ÔÚexecuteÒªÁìÖнç˵ÏêϸµÄʹÃüÂß¼­£¨ÀýÈçʹÃüÖ´ÐÐÀֳɺóÊä³öÄÄЩÐÅÏ¢µÈµÈ£©¡£

Èý¡¢ÔõÑùʹÓÃͼÐλ¯µÄ·½·¨¾ÙÐÐʹÃüµ÷Àí

ÔÚʹÃüÀà½ç˵Íê³ÉÖ®ºó£¬ÎÒÃǾͿÉÒÔ˼Á¿Ê¹ÓÃThinkPHP6¾ÙÐÐͼÐλ¯µÄ·½·¨¾ÙÐÐʹÃüµ÷Àí¡£ThinkPHP6ÌṩÁËÒ»¸öÏÂÁîÀ´Ö´ÐÐʹÃüµ÷ÀíÖÎÀí£ºphp think schedule:list¡£Ö´ÐиÃÏÂÁϵͳ»á×Ô¶¯É¨ÃèËùÓÐÒѽç˵ʹÃüÀ࣬Êä³öʹÃüµÄ»ù±¾ÐÅÏ¢¡£

ÔÚÖÕ¶ËÖÐʹÓÃphp think schedule:listÏÂÁÊä³öЧ¹ûÈçÏ£º

+---------+-----------+--------------------+---------------+------------------------+
| Command | Signature | Description        | Interval      | Timezone               |
+---------+-----------+--------------------+---------------+------------------------+
| test    | test      | ²âÊÔʹÃü           | * * * * *     | Asia/Shanghai          |
+---------+-----------+--------------------+---------------+------------------------+

µÇ¼ºó¸´ÖÆ

´ÓÊä³öЧ¹ûÖÐÎÒÃÇ¿ÉÒÔ¿´µ½£¬Ê¹ÃüÃûΪtest£¬Ê¹ÃüÐÎòΪ²âÊÔʹÃü£¬Ê¹ÃüµÄµ÷Àíʱ¼äΪÿ·ÖÖÓÖ´ÐÐÒ»´Î£¬Ê±ÇøΪAsia/Shanghai¡£

µ±ÎÒÃÇÐèÒªÐÂÔöʹÃüʱ£¬¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁî¾ÙÐУº

php think schedule:add ʹÃüÃû

ÀýÈ磺php think schedule:add Test

µ±ÎÒÃÇÐèҪɾ³ýʹÃüʱ£¬¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁî¾ÙÐУº

php think schedule:remove ʹÃüÃû

ÀýÈ磺php think schedule:remove Test

µ±ÎÒÃÇÐèÒªÐÞ¸ÄʹÃüµÄ»ù±¾ÐÅϢʱ£¬¿ÉÒÔÔÚʹÃüÀàÖеÄconfigureÒªÁìÖÐÐ޸ĸÃʹÃüµÄÐÅÏ¢¡£ÐÞ¸ÄÍê³ÉÖ®ºó£¬Ö´ÐÐÒÔÏÂÏÂÁî¾ÙÐУº

php think schedule:clear // Çå¿ÕʹÃü

php think schedule:list // ÖØÐÂɨÃèʹÃü

Ö´ÐÐÒÔÉÏÁ½¸öÏÂÁîÖ®ºó£¬¼´¿É¿´µ½ÒѾ­Ð޸ĺóµÄʹÃüÐÅÏ¢¡£

ËÄ¡¢ÔõÑùÖ´ÐÐʹÃüµ÷Àí

µ±ÎÒÃǽç˵ºÃÁËʹÃüÀà¡¢ÉèÖúÃÁËʹÃüµÄÐÅÏ¢Ö®ºó£¬ºóÃæ¾ÍÊÇÔõÑùÖ´ÐÐʹÃüµ÷ÀíµÄÎÊÌâÁË¡£

ÔÚÖÕ¶ËÖ´ÐÐÒÔÏÂÏÂÁ¿ªÆôʹÃüµ÷Àí£º php think schedule:run

ÔÚÖÕ¶ËÖ´ÐÐÒÔÏÂÏÂÁÉó²éʹÃüµ÷ÀíÁÐ±í£º php think schedule:list

ͨ¹ýÒÔÉÏÁ½¸öÏÂÁÎÒÃÇ¿ÉÒÔ¿ªÆôʹÃüµ÷Àí²¢Éó²éʹÃüµ÷ÀíÁбí£¬ÏµÍ³»áƾ֤ʹÃüµÄµ÷Àíʱ¼ä×Ô¶¯Ö´ÐÐʹÃü¡£ÔÚÖ´ÐÐÀú³ÌÖУ¬ÎÒÃÇ¿ÉÒÔͨ¹ýÈÕÖ¾À´¾ÙÐÐÉó²é¸÷¸öʹÃüÖ´ÐеÄÇéÐΣ¬ÈÕÖ¾µÄ·¾¶ÎªruntimeĿ¼ÏµÄschedule.logÎļþ¡£

Îå¡¢×ܽá

±¾ÎÄÖ÷ÒªÏÈÈÝÁËÔõÑùʹÓÃThinkPHP6¾ÙÐÐͼÐλ¯µÄʹÃüµ÷ÀíÖÎÀí¡£Ê×ÏÈͨ¹ýcomposer×°ÖÃthink-schedule¿â£¬²¢ÔÚʹÃüÀàÖнç˵¸ÃʹÃüµÄ»ù±¾ÐÅÏ¢ºÍÏêϸµÄʹÃüÂß¼­£¬Ö®ºóͨ¹ýÏÂÁîÀ´¾ÙÐÐʹÃüµÄÐÂÔö¡¢É¾³ýºÍÐ޸ġ£ÔÚʹÓÃphp think schedule:runÏÂÁ¿ªÆôʹÃüµ÷Àíºó£¬ÎÒÃÇ¿ÉÒÔͨ¹ýphp think schedule:listÉó²éʹÃüµ÷ÀíÁбí£¬ÏµÍ³»áƾ֤¸ÃʹÃüµÄµ÷Àíʱ¼ä×Ô¶¯Ö´ÐÐʹÃü¡£×îºó£¬ÎÒÃÇ¿ÉÒÔͨ¹ýÈÕÖ¾À´Éó²é¸÷¸öʹÃüµÄÖ´ÐÐÇéÐΡ£

ÒÔÉϾÍÊÇÔõÑùʹÓÃThinkPHP6¾ÙÐÐͼÐλ¯µÄʹÃüµ÷ÀíÖÎÀí£¿µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±ÊµÊ±ÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
¡¾ÍøÕ¾µØͼ¡¿¡¾sitemap¡¿