search

Home  >  Q&A  >  body text

How to implement PHP service scheduled tasks?

How to execute a certain program on the server every period of time, please give me some ideas.

typechotypecho2772 days ago805

reply all(4)I'll reply

  • 迷茫

    迷茫2017-06-23 09:13:52

    The server crontab sets a scheduled task, and the scheduled task runs the PHP file in CLI mode.

    PHP CLI mode documentation:
    http://php.net/manual/zh/feat...
    crontab documentation:
    http://www.cnblogs.com/peida/...

    Update

    In the comments, I saw someone asking whether it is linux or windows, so I will also talk about the operation method of windows.
    In the above idea, PHP CLI mode runs php files, this remains unchanged;
    Scheduled tasks can Use the scheduled tasks that come with windows to execute.

    reply
    0
  • 迷茫

    迷茫2017-06-23 09:13:52

    linux crontab
    Self-Baidu

    reply
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-06-23 09:13:52

    crontab, queue, redis, etc. can be combined to achieve scheduled tasks

    reply
    0
  • 扔个三星炸死你

    扔个三星炸死你2017-06-23 09:13:52

    1.linux crontab

    * * * * * command
    

    (minute, hour, day, month, day of week, command to be executed)

    2. Message middleware

    3. PHP loop hangs

    It is recommended to use the first method for simplicity.

    reply
    0
  • Cancelreply