Start & Stop PHP Script from Backend Administrative Webpage

后端 未结 2 1930
你的背包
你的背包 2020-12-22 08:03

I\'m trying to create a webpage that will allow me to start and stop of a PHP script. The script is part of the backend of a site, and will need to access, read data from, p

2条回答
  •  隐瞒了意图╮
    2020-12-22 08:58

    To run a script which run continually, you need think to that:

    • Your php script should be launched as CLI (command line) by a job scheduler like cron or something else. Don't forget that your web server configuration defined a timeout on executed script.

    • To run 24h a day, maybe you imagine to implement an infinite loop. In that case, you can write a test like jobIsActive which read in a file or in the database every loop if the job should be executed or not. If you click on the button just change the job status (update file, db ...). Your both button can stop the treatment or activate it but doesn't stop the infinite loop.

    • An infinite loop isn't the most elegant solution, why don't you write an entry in the cron tab to execute the job each night and a click on a button can fired it manually.

提交回复
热议问题