Recently encountered in the development of a scene, the Background administrator batch audit users, need to send users to audit through information, some people may think of using a foreach loop to send, the general SMS interface has a call frequency, loop send, will certainly lead to some of the information sent to fail, some people say with sleep () Sleep for a while, this also can not, if encountered the user more situation will certainly lead to PHP execution timeout, landlord reference online solution, there are 2 kinds of solutions, the first is to use the queue, more commonly used has RABBITMQ, this one cross-multilingual message queue implementation, the function is very powerful, specifically can Baidu, because this scene is small , not to use RABBITMQ, there is a solution, is to use the Linux task plan, Crond,
1, in Linux Crond is managed by crontab, enter CRONTAB-E in the terminal can create a new task, the format of the task is: * * * * * [executed script]
2, each * number represents the time of day and Moon week, for example, I need not half an hour to perform an operation: */30 * * * * Curl/Domain name/controller/operation, can also be specified in range: 0,30 7-22 * * * Curl/Domain name/controller/operation Represents every half-hour between 7 and 10.
3, the first time the audit user ID into a queue table, the table has the user's corresponding phone number,
4, then write a send operation, remove 5 at a time,
5, then open a timing plan to perform this operation, after the new task, service Crond Restart Restart plan, then service Crond status can see the task is running,
Note: The new process is the VI command operation, after the new WQ must be saved
PHP Bulk Send SMS or email scheme