문제

I want to create a feature on my website that allows users to schedule a post at a specific time. The posts will be placed in a queue and then posted at the specified time. What is the proper method for handling this? Do I need to create a separate cron job for each individual scheduled post?

도움이 되었습니까?

해결책

Typically this is done with a single cron job acting as "trigger". That trigger (a php script) checks the list of pending jobs in the database and executes one or more.

It might spawn sub requests for each job to improve robustness, but this adds load to the system.

It is important to mark started jobs inside the database so that in case of concurrent trigger processes (whyever, for example system load), a single job is not started twice. This is especially true for jobs that crash...

You might also want to implementing a locking strategy, so that only one single concurrent trigger request is possible.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top