Reference: Signal processing practice in shell scripts the signal trap function of the Linux shell you must know the details in Unix, each type of event that can occur is described by an independent signal, each of which is a small positive integer,
Requirements: accurately monitor CPU with top commandPreparation knowledge: Top use, basic awk, DC (default bash shell does not support decimal operations)The script is as follows[[email protected] scripts]# cat cpu.sh #!/bin/bash -# top -n 参数指定运行次数,
1. Download Peanut Shell 2. Find the Linux version to download3. Installation, the new version of the Linux version is in the form of SN code4. This is the start command of the peanut shell relatedNote: If you use the previous version, if you use
Variable substation and global variables in the shellBash's variables are global variables by default, and can be called within a script, regardless of where (and in the body of the function), a variable in the function body can be called outside
1. Needs and ideasRequirements: Use the shell to customize a variety of personalized alarm tools, but the need for unified management, standardized management.Idea: Specify a script package that contains the main program, subroutine, configuration
Iv. conclusion of the experiment1. Practice command history, aliases, and special character usages in the shell (4th. 4.2, Section ~4.5)2. Shell Command Application Exercise(1) The use of the following documents is briefly reviewed through the Help
Shell Alarm System
Demand:Use Shell to customize a variety of personalized alarm tools, unified management, standardized management;
Ideas:Specifies a script package that contains the main program, subroutine, configuration file, mail
Purpose and Requirements:When porting, you need to integrate the new content in the root filesystem rootfs1 into the ROOTFS2, but not the things rootfs2. That is, you can only compare the similarities and differences of two file systems, moving more
1:hbase start hbase Shell Run command class path contains multiple slf4j Bindings. Error, because the jar package conflicts, so for the jar package with Hadoop, you can delete the other jar package, if you are not sure whether the deletion is
Case one:"LVS Client Node" Development LVS Client Set VIP and Admin script to suppress ARPScript content:#!/bin/bash############################################################### file name: lvs_ client.sh# version: v1.0# author: da ya# organization:
If condition test statement
If-then-fiThe IF condition test statement runs the command after the if (judgment).If the exit status code for this command is 0, the command in the then section will be executed.If the exit status code for the
For statement1. For statement1) IntroductionIn the actual work, often encounter a task to be executed multiple times. Each execution is simply a different object, with the same other commands. For example, create a system account based on the list
Shell Color and Flicker control
Sometimes custom output is required under the shell, such as adding color to the output, highlighting it, or adding flicker.Then these color codes or control codes are relatively bad to remember. At this
Logical-judgment logical expressions in shell scripts are used in [] (brackets):
-lt:=little than less than
-le:=little && wqual less than equals
-eq:=equal equals
-ne:=no Equal Not equal to
-gt:=greater than greater than
Let's start with an example: Suppose you have a test service that can start, shut down, or restart test by command, the following script simulates this feature:#!/bin/bash#test.shcase $ in start) echo "Starting service ..." sleep 1
Script Realization Man-machine Game, Machine Application random method, combined with user input to give the result, the article has two methods, the first method is the logical aspect of the script, the second is easier to understand.One: The
Shell Script third-- Monitor the host's disk space and send mail to warn when more than 90% space is used#!/bin/bash#monitor available disk space#提取本服务器的IP地址信息ip= ' ifconfig eth0 | grep "inet addr" | cut-f 2-d ":" | Cut-f 1-d "" 'space= ' df-hp |
#!/bin/bash# Remove site Data web= ' cat website.txt ' if [-Z ' $web '];then #判断长度如果为0 true. No need to test Web site echo "Data that's not tested" exit 1fitest-f result.log && rm-f result.log #test-F if it's a normal file then true Functi On delay {
A function in the shell1 understand several system variables of the script first$# 是传给脚本的参数个数$0 是脚本本身的名字$1 是传递给该shell脚本的第一个参数$2 是传递给该shell脚本的第二个参数[email protected] 是传给脚本的所有参数的列表$* 是以一个单字符串显示所有向脚本传递的参数,与位置变量不同,参数可超过9个$$ 是脚本运行的当前进程ID号$?
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