Demand:
Daily 2:10 back up the database zhengdb to/data/backup/db.
The start and end of the backup can give the appropriate information.
The backup file identity standard is the backup time as the file name, and packaged into a. tar.
We can pass parameters to the script when executing the Shell script, and the format of the parameters obtained in the script is:$n.n represents a number, 1 is the first argument to execute the script, 2 is the second argument to execute the script,
Var=value//This is a value assignment.Note that there is no space between the variable and the value, otherwise it will be considered equivalent judgment, such as [var = valu E]//equivalent judgment, the space is particularly important!!!#!/bin/SHCD
1.shell is a batch program, similar to the Windows BAT file2. When writing the shell, the first line should be #! /bin/bash begins Execute the file using the bash shell.3. Use the # comment (preferably note the function of the shell script in case
scene: In peacetime work, often need to perform some scheduled tasks, and when the timing of the failure to perform tasks need to come to the nail group, using the [nail robot] can easily and quickly help us do this thing.
Simple to use
Five, Shell Process Control1. A heavy BranchIf statement syntax format:If conditionThenCommand1FiThe FI at the end is the if inverted.Write a line:if condition; Then Command1; Fi2. Two branchesIf ELSE syntax format:If
Learning about Linux, some time ago to learn the shell script, wrote a very simple script, remote other virtual machine to partition the disk, their own pure hand, but also a record of individual learning process, the great God can skip!Here is the
1 If ... else ...Basic Format:If conditionThenCommendElseCommendFi Of course you can write to a line, use [] to indicate the boundary, or to indicate a branch. For example: if [ $ (ps -ef | grep -c "SSH" ) -gt 1 ];then echo "true" ; fi
There are many types of for loops in shell scripts, and a brief summary of the following is done today.1. Cyclic Digital#!/bin/bash for((i=1; i; i++)); do Echo $ (expr31); Done #!/bin/bash for i in $ (seq 1 10 ) do echo $ (expr $i
#!/bin/bash#截取字符串#path =ss/usr/share/src/root/home/adminPath=ss/usr/share/src/root/home/admin/src/addEcho $pathEcho ${path%src*} #从右向左截取第一个 the string after SRCEcho ${path}Echo ${path%/*} intercepts the first/second string from right to leftEcho
A 1.shell programming language is a dynamic language (a weakly typed language) that interprets side execution at run time, does not need to be declared before it is used, is declared in use, and does not even differentiate between variable types,
1. Use a command to find the files that have been modified in the last 24 hours in the/etc/directory, and the suffix name isthe. log file and delete it.Find/etc-type f-mtime-1-name "log* "-exec rm-rf {} \;2. From the Test.log file, find the row
If...elseif [$1x = = "AB" x]; Then echo ' You had enter AB ' elif [$1x = = ' CD ' x]; then echo ' You had enter CD ' Else echo ' You had enter UNEXPE CTED word "fi Case...esacA switch case similar to another language, however, here is a
Shell and shell scripting differencesShell: Refers to an application that provides an interface through which the operating system kernel services can beShell script: A script written for the shellExecution of Shell scriptsPass./execute instead of
$: The file name of the current execution script$n: N is the natural number, the first parameter is $ A, the second argument is $, and so on$#: Number of parameters$*: All parameters, a string, for example,./a.sh 1 2 3, then $* is "1 2 3"[Email
One: Shell introductionThe shell is a command interpreter that provides interaction between the user and the machine, supports specific syntax, and each user can have his or her own specific shell,centos default of bash, and Zsh,ksh.Two: Command
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