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:
have background job run cronjob every minute (instead of loop can cause memory leaks). php not designed daemon.
set db flag in cronjob on/off, everytime runs checks if on or off, if off exists if on continue.
in ui turn flag on or off depending on admin needs.
i think best way go (and easiest).
Comments
Post a Comment