Shell script to back up the database

#!/bin/bash#back_mysql by 2016-11-14bak_dir=/data/backup_db/' Date +%y%m%d 'Mysqldb=mysqlmysqluser=*****mysqlpw=******If [$UID-ne 0];thenecho "must to being use as root for exec shell"ExitFi#判断是否存在文件, \033[32m is the color of the displayif [!-D $bak

Shell periodically deletes files before the specified time

TemplateCat delbak.sh#!/bin/shlocation= "/root/sqlbak/"Find $location-mtime +30-type f |xargs rm-fPs:Location is the directory where the lookup is set--mtime +30 is set time is 30 days ago-type F this week the type of lookup is fileThen add crontab

debugging shell scripts in Linux

The original script check.sh:Monfile= "/var/log/test/testmon.txt"Logfile= "/var/log/test/testmon.log"Touch $monfile...The script is edited in window and uploaded to Linux after editing.Problem:After running, the file that appears in the directory is

Write a shell every day.

1. Read basic reading 1 #!/bin/bash 2 #testing the Read command 3 4 Echo " Enter you name: " 5 Read name # 6echo"Hello $name, Welcome to my program. " Perform:#./read. SH Enter

Shell script implementation randomly sampled class students

Tag:style   date    Implementation    bin   nbsp    and    extracting    cti   bsp    #/bin/bashfunction rand () {min=$1Max=$ ($2-$min +1 ) num=$ (date +%s%N)Echo $ (($num% $max +$min))}rnd1 the ) JW=(Wang Hao Shein Huang Yang Hoxing Yu Hu Jiang

Shell script re-mounts the problematic volume

#!/bin/bash#卷的全路径示例#pathexample =mount-t Cetusfs 127.0.0.1:/cinderv/var/lib/cinder/volumes/0f6a20f4d81ed9db37f2a87260dd7181Volumespath= ' Df-h |awk ' {print$1$6} ' |grep volumes ' #获取卷路径pathrow= ' Df-h |awk ' {print$1$6} ' |grep volumes|wc-l '

Linux Shell Text filtering

Regular Expression - concept: A special syntax for describing text patterns -by ordinary characters (e.g., characters A to Z), and special characters (metacharacters, such as/ *?). And so on) make up a matching string--the text Filter tool supports

CENTOS7 shell script Implementation random number

Questions1. How random numbers are obtained2. How to determine the size of the random value is what we needAnswers1. Can now be obtained by obtaining the number of milliseconds of the system time, after all, the number of milliseconds changes

Shell script, the begin explanation in awk.

Explain:begin{} The most common use of this particular pattern is variable assignment. Begin this pattern is when the file does not begin to read.awk ' begin{fs= ': "; ofs="-"}{nf+=0}1", corresponding processing is 1:2:3---------> read the input

Shell Script Review Little Exercise

1. Change the suffix ". sh" suffix to ". Shell" under the/OPT directory (including subdirectories)2. Renaming files A1, A2, A3 files in directories A, B and C to A4, A5, A63. How to change the AA string in the file to BB in the VI

Shell script Application (i) case

Case One• Write a login welcome script for ROOT to report the number of processes in the current host, the number of logged-in users, and the disk usage of the root file system.1. Using the VIM command in the /root directory is a new script file

The use of parentheses inside the shell

Middle BracketBrackets are divided into single brackets [], and double brackets [[]], and brackets are commonly used in expression judgments, and parentheses can also be used in expressions, as mentioned later.Single brackets []a=5b=3[$A-eq $B]

Shell timed Tasks

1. Know CronCron is a timed execution tool under Linux that can run a job without human intervention. Since Cron is a built-in service for Linux, it does not automatically get up, and you can start and shut down this service in the following

[Boiled water]-shell-from numerical N to M (n<m)-Knowledge point

Title: Numerical N accumulates to M (nIn the following example, the examples are 1 to 100, and they can be brought into N and M (nFor loop implementationSum=0for ((i=1;iBy using variable arithmetic to implementEcho $[$ (Echo +{1..100})]echo $ (($

The grep command for Shell programming

grep formatgrep [Options] [mode] [file ...]-C outputs only the number of matching rows-n Lists all matching rows and displays line numbers-V Displays all lines that do not contain matching text-R Recursive Search-E supports extended regular

Shell script in the background execute commands &

Recently encountered a problem,Execute script, script calls a command, command (Deamon) is a daemon, in order to debug, the daemon mode is canceled. The other commands behind the command (echo "456") cannot be executed.Deamon-d is initiated in

Shell in && | | The method

Shell && and | |When the shell executes a command, it returns a return value that is saved in the shell variable $? In When $? = = 0 o'clock, indicating successful execution; = = 1 o'clock, which indicates that the execution failed.Sometimes the

Monitoring NTP shell scripts

[Email protected]/]# cat/home/monitorntp.sh#!/bin/bash# Process NameProc_name= ' Ntpd-u '# log fileFile_name= "/home/logs/ntpd.log"Pid=0# Number of calculation processesProc_num (){Num= ' Ps-ef | grep "$proc _name" | Grep-v grep | Wc-l 'return $num}#

Interception of Shell strings

directly on the code.1linux- About:/Install#Cat 3.SH 2#!/bin/SH3Str=HelloWorld4 Echo 'STR = ='$STR5 6 Echo${STR:5:5} # ==Echo${STR:5} #结果为World7 Echo${STR:5} # Use: ${str:begin:len} #结果为World 8 9 ExprSubstr"$STR" 6 5 #结果为World Ten One Echo$STR |awk

KVM One-click Shell automatically generates a Windows virtual machine with unattended operation scenario (STEP1)

KVM One-click Shell automatically generates a Windows virtual machine, unattended operation scheme is divided into four steps to complete the joint;The first step: Start the startup script, so that the machine can be executed at the start of the

Total Pages: 541 1 .... 535 536 537 538 539 .... 541 Go to: GO

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.