First, alarm system mail engine[[email protected] mon]# lsbin conf log mail shares[[email protected] mon]# cd mail[[email protected] m ail]# vim mail.py//Create send mail script #!/usr/bin/env python#-*-coding:utf-8-*-import os,sysreload (SYS)
First, Shell introduction1, the shell is a command interpreter, providing users and machines to interact, each user can have their own specific shell,2, CentOS7 default shell for bash, and Zsh,ksh they have the difference in detail,We can check if
1. ExercisesDesign a script that monitors the surviving state of a remote host (assuming the IP address is 110.110.110.114) and sends a message to yourself when it finds an outage.Tips:
You can use the ping command:
ping -c 10 110.11
Judging command testYou can use the test command to perform tests on files, strings, and so on, typically with control statements such as While,if,case"字符串测试" ? test str1==str2 测试字符串是否相等 ? test str1!-str2 测试字符串是否不相等 ? test str1 测试字符串是否不为空 ? test -n
Hello everyone, I am the lone cloud twilight rain, brought to you today is the "Linux shell script several circular statements to create the user's method"Add USER1~USER20 UserFor loop:#!/bin/bashfor i in {1..20}douseradd User$iecho ' user$i Users
Shell IntroductionDuring the development process, the Linux system is frequently contacted and used, and the shell is a bridge for our users to use Linux, and is a program written in the C language. The shell is a command language, as well as a
1. Logical operators;Logical operator Instances:A=Tenb= -if[$a! =$b]then Echo"$a! = $b: A! = b"ElseEcho"$a! = $b: a = b"fiif[$a-lt --A $b-GT the]then Echo"$a less than 100 and $b greater than 15: Returns True"ElseEcho"$a less than 100 and $b greater
$ A This is the path to the script file itself (relative path)If there is an execution script file under the current directory, you cannot write an absolute path for execution.$# this variable to record the number of input parameters6 is the number
Linux Shell functions
Write in front: function, this word in just the beginning of the classmate looks very tall, in fact, the shell inside the function is very simple, function is actually to reduce the amount of code, so this space may be
In Linux has been learning for one months, today to write a small script, wrote three different, although simple, but you can see, I wrote the script is ping3 times to see if the host is alive!The first one is ~ ~ for~~ loop because I knocked it
$ Current PIN name$# the number of arguments passed to the scriptThe first parameter, and so on$*,[email protected] All parameters$$ Current Shell Process IDShell output shell name, PID, number of parametersList parameters in sequence#!/bin/bashecho"
one, special characters 1.Any character of ' * '‘? ' Any one character' # ' comment characters' \ ' de-semantic characters' | ' Pipe characterMost of them have been used before, for the caret ' \ 'Examples of the use of the caret2. Several
1. Record the command:!!! : Continuous "! "indicates that the last instruction was executed! N: Represents the second instruction in the execution of the command historyNote:! 2 actually shut me down.! String (string greater than 1) indicates the
Exercise 1: Monitoring disk usageRequirements: Write a shell script that detects all disk partition usage and inode usage and logs to a log file named after today's date, and notifies you when a partition capacity is found or the Inode usage is
First, Shell discussionSecond, the script execution modeCreate and open a shell scriptVim Hello. SHEdit#!/bin/Bash#-E allows echo to support Shell escape character echo"\e[1;34m First shell script \e[0m"Run#赋予权限, running (common) chmod 755 Hello. SH
The use and setting of a variable (note that there can be no spaces before and after the equals sign)1. ReadRead the input from the keyboard assignment to the variable, using the following method[Email protected]:/opt/android-sdk/sdk/# read
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