Site was DDoS attack, so wrote a foot to resist, to achieve the way:
1. Attack characteristics, different IP constantly post Web page, resulting in excessive resource consumption2. Analyze Nginx Access log, Judge post feature to obtain Client
In order to more easily know the memory usage on the server, and according to the memory use size to restart the service, I only the whole fault alarm, if you want to automatically restart the service, we will have to modify their own.
Script
Principle: awk command, split formatted TXT (TXT file format with "|") divided) into groups, then spliced into HTML format (html-head-title-body-table)
Shell Source
#!/bin/sh file_input= ' txt.log ' file_output= ' txt2html.html ' td_str= '
> and when it comes to I/O redirection, let's get to know file descriptor (FD) first. The operation of the program, in most cases, is the processing of data (data), which is read from where? And where to send it? This is the function of file
If you manage more sites and servers, every time you modify a configuration file, it's pretty painful. The idea is to use a shell script to generate bulk configuration files and configuration data. The following script is a shell script for batch
Previously used Ubuntu, the installation of uninstall software is basically using apt-get this very simple, and the process of software dependencies will automatically help us deal with, similar to the fool-like installation. In addition, in the
The Linux shell can be user-defined, and can be invoked randomly in a shell script. Here's how it's defined, and what the call needs to pay attention to.
First, define the shell function (define functions)
Grammar:
[Function] funname [()]
1, login to the host and enter ssh-keygen-t RSA
Prompt for enter file in which to save the key (/ROOT/.SSH/ID_RSA):
Input/root/.ssh/sea_rsa
Enter the relevant pathname and filename as prompted and generate two files (followed by two options to
First, Shell introduction
The design of many Unix-like operating systems is stunning. Even today, the UNIX-style operating system architecture remains one of the best designs ever. One of the most important features of this architecture is the
Method 1: Add a variable to an integer value by using expr, or an integer if it is performed correctly, or an error is executed, $? will be a value that is non 0
Copy Code code as follows:
Expr $args + 0 &>/dev/null
Method 2
#/usr/bin/env Bash
# Name:get_network_info.sh
# author:purple_grape # This was
a script to gather network inf Ormation of your Linux system.
# Test under Ubuntu 10.04 only.
#----------------------------
nic=eth0
mac= ' lang=c ifconfig $NIC | awk '/
BASH shell set font and background color
Echo-e "\e[31mtest\e[41m"
\e[30m change the display color of a character to black
\e[31m change the display color of a character to red
\e[32m change the display color of a character to green
\e[33m change
1. Take today's time
Copy Code code as follows:
$date-D "Now" +%y-%m-%d
2. Take yesterday time
Copy Code code as follows:
$date-D "Yesterday" +%y-%m-%d
$date-D "1 days ago" +%y-%m-%d
# # D,--date=string
Many people use shell scripts to accomplish simple tasks and become part of their lives. Unfortunately, shell scripts can have a very large impact when they run an exception. It is necessary to minimize this type of problem when writing scripts. In
Each language has his own string manipulation method, the shell is the same, the following in an example of the way, a simple introduction of common methods.
1, get string length
Copy Code code as follows:
1shell is an interface between the user and the kernel to interoperate,
2shell commands that can be run include Linux commands, built-in commands, utilities, user programs, shell scripts
3shell characters:
4. Get command help: Man,info.--help
5
Scene:The Redis keys value needs to be monitored, and monitoring scripts are executed using the Crond cycle. If there is an exception, notify by email.First, install the MSMTPDownload softwarewget http://sourceforge.net/projects/msmtp/files/msmtp/1.4
The shell itself is a program written in C, which is a bridge for users to use Unix/linux, and most of their work is done through the shell. The shell is both a command language and a programming language. As a command language, it interprets and
[Email protected] ~]#CatJiechen.SH #!/bin/bash# Design a shell program to calculate the factorial of N, required: #1. Receive parameters from the command line n;#2to determine the legality of n immediately after the commencement of the program, that
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service