


I started running a data list a few days ago. The list requires user names, whether they have mobile phone numbers, and whether they have email addresses. I easily obtained the user list. However, there are as many as 20 million users in the list, and I have to check whether the user has Whether there is a mobile phone number and an email address must be requested one by one through a secure interface that is open to the outside world, and then the return value can be analyzed to know.
The following is the solution I dealt with:
1. Save the 2000w list to a temporary data table
2. Use a PHP program to retrieve the list every time Get 500 users from the table, and generate the original SQL update record after detection
3. In order to prevent the PHP program from suddenly disconnecting, use a shell script to detect every 1 minute. If PHP fails, restart it
I use the shell script as The reason for the daemon process is that the detection interface between mobile phones and mailboxes is slow, and it is impossible to detect 20 million users in 1 to 2 days.
Details of the plan:
1. Temporarily save the user list table users, the table structure is as follows:
CREATE TABLE `users` (
`account` varchar(50) COMMENT 'username',
`has_phone` tinyint(3 ) unsigned NOT NULL default '0' COMMENT 'Do you have a mobile phone number',
`has_email` tinyint(3) unsigned NOT NULL default '0' COMMENT 'Do you have an email',
`flag` tinyint(3) unsigned NOT NULL default '0' COMMENT 'flag',
PRIMARY KEY (`account`),
KEY `flag` (`flag`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=' List table';
I first imported more than 2,000 user names into this temporary table. The two fields of has_phone and has_email are both 0 (none) by default. The flag indicates whether the user has Testing completed.
The following is part of the table data:
9873aaa,0,0,0
adddwwwd876222,0,0,0
testalexlee,0,0,0
codejia. net,0,0,0
haohdouywaa21,0,0,0
2. PHP script check_users.php
After importing the user list into the table, write another A simple PHP script, the idea is as follows: each loop retrieves 500 users with flag=0 from the table, then requests the interface to determine whether the user has a mobile phone number and email address, generates a SQL, saves it to an SQLS array, and waits for 500 After all users have been tested, loop the SQLS array, update the 500 lists in the table, and set the flag flag to 1, indicating that the test has been completed and will not be obtained next time.
Since the PHP script code is long, here is a simple code description:
class Users{
private $data;
private $sqls;
private $nums; //Determine whether there are 500 users
private $total_nums; //Currently detected Completed number of users
//Get 500 users each time
private function getUsers(){...}
//Detect these 500 users and generate SQL
private function checkUserInfo(){...}
//Update these 500 users
private function updateUserInfo(){...}
//Run
public function run(){
$flag = true;
while($flag){
if($this->nums != 500){ $flag = false; }
if($this ->total_nums == 10000){
; $this->checkUserInfo();
$this->updateUserInfo(); }
}
$user = new Users();
$user->run();
?>
The above is a concise version of the PHP script. You probably get the idea. The initial version did not have the $total_nums variable. This is because when I first started running this script, I found that it only ran out of more than 40,000 scripts before it failed. Later, At first glance, it turned out that the script was hanging there because the connection to the database failed. Adding this variable cannot solve this problem, but after running 10,000 users each time, the PHP script exits and is restarted by the following shell script.
3. Shell script as a daemon
I added this shell script to crontab and executed it every 1 minute. This shell script is very simple. It detects whether the process id exists in check_users.php , if it exists, it means that the PHP script is still running, and the shell script does not do anything; if it does not exist, it means that the PHP script has finished exit(0) and the 1w user has exited, then the shell script starts the script and enters the next 1w Detection of user lists.
I mentioned above that if the PHP script cannot connect to the database when it is connected, PHP will always hang there and cannot exit. I added a time detection in the shell script. When the PHP script process exists, calculate how long it has existed. If it exceeds the time I expected, kill the PHP script and restart it.
, the results are similar to the following:
testalexlee,1,0,1
codejia.net,0,0,1
haohdouywaa21,1,1,1
9873aaa,0 ,1,1
adddwwwd876222,1,0,1
Finally: The above user list data is just an example, don’t take it too seriously. With 20 million data, I estimate it will take a while because the detection interface is relatively slow. After receiving the request, you need to connect the table, look up the table, and then return. In fact, the best way is to pull a list directly from the table requested by the interface, and then use shell commands to process it, and you will get the result quickly. But this is the case in the company, some things are not open, you know~~~

<p>定制您的操作系统是让您的日常生活更加愉快的绝佳方式。您可以更改用户界面、应用自定义主题、添加小部件等等。因此,我们今天将向您展示如何在Windows11上安装ClassicShell。</p><p>该程序已经存在了很长时间,并允许您修改操作系统。志愿者现在已经开始运营该组织,该组织于2017年解散。新项目名为OpenShell,目前在Github上可供感兴趣的人使用。</p>&a
![Explorer.exe 在系统启动时不启动 [修复]](https://img.php.cn/upload/article/000/887/227/168575230155539.png)
如今,许多Windows用户开始遇到严重的Windows系统问题。问题是系统加载后Explorer.exe无法启动,用户无法打开文件或文件夹。虽然,Windows用户在某些情况下可以使用命令提示符手动打开Windows资源管理器,并且每次系统重新启动或系统启动后都必须这样做。这可能是有问题的,并且是由于下面提到的以下因素造成的。损坏的系统文件。启用快速启动设置。过时或有问题的显示驱动程序。对系统中的某些服务进行了更改。修改后的注册表文件。请记住以上所有因素,我们提出了一些肯定会对用户有所帮助

您在运行脚本时是否看到此错误消息“Add-AppxPackage:部署失败,HRESULT:0x80073D02,无法安装该包,因为它修改的资源当前正在使用中。PowerShell中出现错误0x80073D02…”?如错误消息所述,当用户在前一个进程运行时尝试重新注册一个或所有WindowsShellExperienceHost应用程序时,确实会发生这种情况。我们已经获得了一些简单的解决方案来快速解决这个问题。修复1–终止体验主机进程您必须在执行powershell命令之前结束

适用于 Linux 的 Windows 子系统第一种选择是使用适用于 Linux 或 WSL 的 Windows 子系统,这是一个兼容层,用于在 Windows 系统上本地运行 Linux 二进制可执行文件。它适用于大多数场景,允许您在 Windows 11/10 中运行 shell 脚本。WSL 不会自动可用,因此您必须通过 Windows 设备的开发人员设置启用它。您可以通过转到设置 > 更新和安全 > 对于开发人员来完成。切换到开发人员模式并通过选择是确认提示。接下来,查找 W

Linux系统下在处理文件时,有时候需要删除文件末尾的行。这种操作在实际应用中很常见,可以通过一些简单的命令来实现。本文将介绍在Linux系统中快速删除文件末尾行的操作步骤,同时提供具体的代码示例。步骤一:查看文件末尾行在进行删除操作之前,首先需要确认文件的末尾行是哪一行。可以使用tail命令来查看文件的末尾行,具体命令如下:tail-n1filena

Python 脚本部分实例:企业微信告警、FTP 客户端、SSH 客户端、Saltstack 客户端、vCenter 客户端、获取域名 ssl 证书过期时间、发送今天的天气预报以及未来的天气趋势图;Shell 脚本部分实例:SVN 完整备份、Zabbix 监控用户密码过期、构建本地 YUM 以及上篇文章中有读者的需求(负载高时,查出占用比较高的进程脚本并存储或推送通知);篇幅有些长,还请大家耐心翻到文末,毕竟有彩蛋。Python 脚本部分企业微信告警此脚本通过企业微信应用,进行微信告警,可用于

无法在Windows 11上运行的 Open shell 并不是一个新问题,并且自从这个新操作系统问世以来一直困扰着用户。Open-Shell Windows 11 不工作问题的原因并不具体。它可能是由程序中的意外错误、病毒或恶意软件的存在或损坏的系统文件引起的。对于那些不知道的人,Open-Shell 是 2017 年停产的 Classic Shell 的替代品。您可以查看我们的教程,了解如何在 Windows 11 上安装 Classic Shell。如何替换 Windows 11 的开始菜

OpenShell是一个免费的软件实用程序,可用于自定义Windows11开始菜单,使其类似于经典风格的菜单或Windows7样式的菜单。以前版本的Windows上的开始菜单为用户提供了一种浏览其系统内容的简单方法。基本上,OpenShell是ClassicShell的替代品,它提供了不同的用户界面元素,有助于从以前的Windows版本获取后一个版本的功能。一旦ClassicShell的开发在2017年停止,它就由GitHub志愿者以OpenShell的名义维护和开发。它与Win


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

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

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.

Dreamweaver CS6
Visual web development tools

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
