Starting / Stopping php script running in background from browser -


i'm pretty new php. first time actually, apologize in advance if question sounds dumb.

i have php script fetches data external api , updates database regularly. know best way use cron job. however, using infinite loop sleeps particular time between each update.

now, need allow user (admin) start / stop script , allow them change time interval between each update. admin through ui. best way this? how execute script in background when user clicks start , how stop script?

thanks.

i think ideal solution following:

  1. have background job run cronjob every minute (instead of loop can cause memory leaks). php not designed daemon.

  2. set db flag in cronjob on/off, everytime runs checks if on or off, if off exists if on continue.

  3. in ui turn flag on or off depending on admin needs.

i think best way go (and easiest).


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -