Xjjdog (xjjdog)

I am very proficient in Linux, especially in scripting languages such as sed, AWk, Python, etc. I think of it as a very unique skill for me, one that sets me apart from the average programmer. So when I’m writing scripts, I proudly hold my head up, nose up, and Muse on the lean code.

Xjjdog, for example, felt bad when someone had to go through the documentation to install ElasticSearch, so he wrote a script to speed up the process.

mkdir /data
useradd es -d /data/es
chown -R es:es /data
cat > /etc/security/limits.conf <<EOF
* soft nofile 65536
* hard nofile 65536
* soft noproc 65536
* hard noproc 65536
es soft memlock unlimited
es hard memlock unlimited
EOF
cat > /etc/sysctl.conf  <<EOF
vm.swappiness = 0
vm.max_map_count = 262144
EOF
sysctl -p
chown -R es:es /opt/elasticsearch
Copy the code

This script allows me to quickly understand the essentials of software installation without having to read lengthy documents. Like this, I always do, as time goes by, make oneself seem very idle. Take a look at the command line I shared earlier.

The most common set of “Vim” techniques the most common set of “Sed” techniques the most common set of “AWK” techniques

These days I see Xiao Wang has been tinkering with Excel. He has been dealing with these data for several days. The customer needed to migrate to our platform from another platform, and exported a bunch of bad data, like 30 or 40 MB. Somehow, the job of cleaning the data fell to Xiao Wang.

The files are huge, and the company’s computers suck. When Xiao Wang turned it on, the computer fan whirled. Each time he needs to press CTRL + F to find the abnormal data and copy it to another file. Data for a tight period of time, last night, Wang worked overtime to 23 o ‘clock, until the end of the night.

The director singled it out for praise.

As I sit next to Xiao Wang, I can’t sit idly by. Years of habit have made me as intolerant of inefficiency as a running rabbit of a snail.

After a quick glance at Xiao Wang’s requirements, I decided that a three-day task could be completed in 2 hours using the script. I’m not being helpful, but I really enjoy writing this script and the thrill of the speed difference.

An hour later, I handed xiao Wang the debugged Python script. As soon as the shell runs, the correct file comes out. It feels so good.

Xiao Wang naturally bowed to me and bragged about his dog to everyone he met.


The matter was somehow known by the superintendent, and I was summoned to the large office. Seeing the director’s sullen face, I knew something was wrong, but I didn’t know the cause. I just joined this company, I should not inadvertently touched the bottom line should not be crossed, my heart is full of confusion.

“I heard you helped Xiao Wang solve a problem.” “Write less of that in future,” said the director.

“Why? “I can’t believe my ears,” scripts can dramatically increase productivity.

“I knew you’d have that question. “The director’s serious face softened and he told me a story about an architect.


Xiao Song used to be an architect of the company. There are a lot of tripod architects who don’t write code, so Soong becomes a rare architect who can code words. One of his stunts was writing scripts, just like I do now.

Scripts increase efficiency, something I’ve learned over the years. But efficiency, by itself, is impossible to measure. So efficiency is a word that you can’t quantify. Even if you cut the project from three days to two hours, you’re not necessarily productive, because it’s just one of those little things that you’re doing, and you’re still fishing. Your efficiency breaks the normal research and development cycle, but also the dream of students who want to work hard. Therefore, increasing efficiency, which has a practical effect, is not a matter of elegance, but a matter of joy in a small circle, and eventually becomes a slogan.

Song’s script was first used to deal with an online accident. At that time, there was a BUG in the program. Some data in the database and cache was out of order, resulting in inconsistencies. Because the cache is distributed across more than 20 machines, you can’t use the method of clearing all the cache.

The business manager was anxious, and after some discussion, decided to develop a scheduled task that scanned all caches and all records in the database, and then corrected the data. The amount of data is large, the program needs to be verified, and the estimated repair time will be at least two days.

‘It’s not that much trouble,’ Mr. Song said. All you have to do is give me all the business logs from the time the problem occurred.

For the next three hours, Song filtered through the logs all the keys that had been updated during the problem. After a little thought, the script is used to complete the cache deletion operation of this batch of keys, which is very perfect to solve the problem.

After this incident, Xiao Song was often asked to write scripts to help solve difficult problems. He never tires of taking anything that comes his way.

Everything seemed to be going well, until an online glitch.

The company’s hundreds of machines are all ec2 services on the AWS platform. You can do a lot with the apis provided by EC2. But ec2’s commands were too difficult to understand, so Song made a package.

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html
Copy the code

With this script, you can batch manage some or all machines (add groups, assign permissions, etc.) without logging in to the background to do some administrative work. Every time Song sees the characters flowing on the black screen, he thinks, this is the charm of efficiency.

The script worked so well that it was distributed. One of the ops got hold of the script and wanted to verify it online.

He sent a shutdown order to all the machines.

The company blew up right away, and there was always going to be wrangling. But in the end, the blame was on Song.

He wrote the script, but he was an architect first. An architect may not write code, may not produce results, but must be aware of risk.

But I didn’t give these orders. This is what the AWS platform provides, and I didn’t do anything about it. Testing these commands has nothing to do with using the script. Xiao Song argued.

But the command was sent through this script, and it did have consequences. Behind those twists and turns of the relationship, no one will go to study, no one will care. Those students who normally enjoy xiao Song’s script are also silent at this time, because this question of responsibility, like efficiency, is a bluff with no clear result.

This kind of thing, small song also experienced. Some people like to run the FLUSHALL command when a redis script is provided. With docker purge, some people like to call docker Purge. It’s impossible to control.

He thinks it’s a matter of the level of the user, not his script. After several quarrels with the director, Xiao Song left in a fit of anger.

He just unfriended everyone in the company and disappeared.


“So I’m asking you this because I’m being kind to you. Compared to the risk, this efficiency gain is really insignificant. At this point, the warden looked at me meaningfully.” I am now in time to stop your behavior, avoid the footsteps of small song.

I nodded. I knew. There was a company that chose Windows as its server just because Linux cost too much to learn and commands were dangerous. Would rather uncomfortable, pay to buy authorization, when 2B, also dare not cross a step. Talk about risk. It’s all the same.

I suddenly felt that all those years of faith were about to crumble. It’s sad to spend so much effort on perfecting the command line, only to end up with no use for it.

“No, director. “I was about to say something when a guy barged in and said,” Someone has changed the root directory permissions to 000 using ansible! “.

The order popped into my head. Linus Torvalds owned the pot this time.

chmod -R 000 /
Copy the code

But the superintendent laughed. “You’re new here. You don’t know what it’s like. This has happened several times this month. It’s time to switch to safe and reliable Windows, and I know people who buy.”

I smiled and nodded, noncommittal, but modestly taught.


I went back to my desk, let out a big sigh, and deleted everyone in the company.

Submit your resignation today. After all, Linus Torvalds can’t be found, but I can. After all, ANsible is a tool I recommended just a few days ago.

So, if you were the architect, what script would you leave behind?

Little Sister Flavor (XjjDog), a GZH that doesn’t allow programmers to get sidetracked. Focus on infrastructure and Linux. Ten years architecture, ten billion daily flow, and you discuss the world of high concurrency, give you a different taste.