linux crontab计划任务有关
现在要跑个计划任务 发短信的。
因为crontab最小只能设置分钟为单位,而短信需要比较快发送。我让一分钟执行发送60条。
从数据库队列表查出未锁定的60条 循环处理的时候 每次更新一个字段表示被锁定。一般短信量很少,1分钟内都执行完了。今天突然一下子有很多,导致一分钟处理60条未处理完,crontab又发出下一次请求。因为是逐个处理完了才做的锁定,所以就出现了并发。(有些短信在这次请求里还未被处理也就会被包含在下一次的请求中)。导致短信重复下发。
一直是想改进这个的,因为一直量比较少,没用心考虑。
应该是将查出来的60条 全部锁定后再做下发处理。但是何时解锁是个问题。
利用第三方队列服务:
想把短信存到数据库,其自增id存到memcacheq中,然后定时执行。(定时执行好像也不行,一分钟一次太慢。用php写个死循环作为守护进程?(可以设置个休息时间)这样一直执行着是否吃内存厉害?)
想知道网站关于下发短信一般是怎么做的?没有守护进程没法做到即时发送吧。。。
------解决方案--------------------
好像弄得有些麻烦?
可以写个shell脚本,每秒用curl请求一次(可以不等请求结束,也可以等执行完再等1秒后发送下次请求),设置一个步长(每次发送的最大数量),然后每次取与步长相同个数的短信,先把它们锁定,然后再逐个发送,即使发送未完成时下一次请求被执行了,这一部分也不会重复发送。
------解决方案--------------------
我这边都是用JAVA做的, 正如你所说的要用守护进程,
python也行,
php也行,
php写成脚本启动就行了,
------解决方案--------------------
contab 定时调用php程序发短信

PHPisusedforsendingemailsduetoitsintegrationwithservermailservicesandexternalSMTPproviders,automatingnotificationsandmarketingcampaigns.1)SetupyourPHPenvironmentwithawebserverandPHP,ensuringthemailfunctionisenabled.2)UseabasicscriptwithPHP'smailfunct

The best way to send emails is to use the PHPMailer library. 1) Using the mail() function is simple but unreliable, which may cause emails to enter spam or cannot be delivered. 2) PHPMailer provides better control and reliability, and supports HTML mail, attachments and SMTP authentication. 3) Make sure SMTP settings are configured correctly and encryption (such as STARTTLS or SSL/TLS) is used to enhance security. 4) For large amounts of emails, consider using a mail queue system to optimize performance.

CustomheadersandadvancedfeaturesinPHPemailenhancefunctionalityandreliability.1)Customheadersaddmetadatafortrackingandcategorization.2)HTMLemailsallowformattingandinteractivity.3)AttachmentscanbesentusinglibrarieslikePHPMailer.4)SMTPauthenticationimpr

Sending mail using PHP and SMTP can be achieved through the PHPMailer library. 1) Install and configure PHPMailer, 2) Set SMTP server details, 3) Define the email content, 4) Send emails and handle errors. Use this method to ensure the reliability and security of emails.

ThebestapproachforsendingemailsinPHPisusingthePHPMailerlibraryduetoitsreliability,featurerichness,andeaseofuse.PHPMailersupportsSMTP,providesdetailederrorhandling,allowssendingHTMLandplaintextemails,supportsattachments,andenhancessecurity.Foroptimalu

The reason for using Dependency Injection (DI) is that it promotes loose coupling, testability, and maintainability of the code. 1) Use constructor to inject dependencies, 2) Avoid using service locators, 3) Use dependency injection containers to manage dependencies, 4) Improve testability through injecting dependencies, 5) Avoid over-injection dependencies, 6) Consider the impact of DI on performance.

PHPperformancetuningiscrucialbecauseitenhancesspeedandefficiency,whicharevitalforwebapplications.1)CachingwithAPCureducesdatabaseloadandimprovesresponsetimes.2)Optimizingdatabasequeriesbyselectingnecessarycolumnsandusingindexingspeedsupdataretrieval.

ThebestpracticesforsendingemailssecurelyinPHPinclude:1)UsingsecureconfigurationswithSMTPandSTARTTLSencryption,2)Validatingandsanitizinginputstopreventinjectionattacks,3)EncryptingsensitivedatawithinemailsusingOpenSSL,4)Properlyhandlingemailheaderstoa


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Mac version
God-level code editing software (SublimeText3)

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
