Back up Web site content
Copy Code code as follows:
#!/bin/bash
#指定运行的脚本shell
#运行脚本要给用户执行权限
Bakdir=/backup
Month= ' Date +%m '
day= ' Date +%d '
Year= ' Date +%y '
Hour= ' Date +%k '
min= ' Date +%m '
Dirname=
1. Install MSMTP
luther@gliethttp:~$ sudo apt-get install msmtp
2. Edit the configuration script (~/.MSMTPRC is the default profile, or you can specify the profile path using the-C option)
luther@gliethttp:~$ Vim MSMTPRC
#添加如下内容
Defaults
#logfile/
In the previous example of Shell programming, it was mentioned that the shell script was extended and redirected to a file for viewing and debugging http://www.jb51.net/article/62435.htm. However, if there is another situation: redirect only in some
The TR (translate abbreviation) is used primarily to remove control characters from files or to convert characters.
Syntax: TR [–c/d/s/t] [SET1] [SET2] #SET1: Character Set 1;set2: Character Set 2-c:complement, replace the characters except SET1
Copy Code code as follows:
#!/bin/bash
#Description: Delete Files
#===== defines the current year, the month, and the directory where the file resides =====#
Currentyear= ' Date +%y '
Currentmonth= ' date +%m |awk-f ' 0 ' {print $} '
1. Get the file name of the current script, including the path.
Copy Code code as follows:
#写一个测试脚本
Vim test.sh
#内容如下
Dirname$0
Basename$0
#执行一下
bash$ (PWD)/test.sh
#输出如下
/home/jane
test.sh
2. $n get the
To create a random number method:
Copy Code code as follows:
1~~~~
/dev/urandom
In Linux, a device/dev/urandom is used to generate random sequence of numbers. Using this device we can generate random strings when needed.
For example, I have 100 executable files, there is no special relationship between each other, such as code:
Copy Code code as follows:
Job_1
Job_2
Job_2
.....
job_100
Want to use Csh/bash to multithreading call
The first method (Gzexe):
This type of encryption is not a very safe method, but can satisfy the general encryption use, can conceal the password in the script and so on information.It is the use of the system's own Gzexe program, it is not only
1 Prepare the monitoring machineLinux system, normal server can, request:Install SSH client, if you want to send SMS, also need to prepare SMS cat and install Gnokii or Gammu
2 Edit ssh_config configuration file/etc/ssh/ssh_config configuration
A simple shell script to find out if a critical service is running and is suitable for Linux or UNIX operating systems.The script can also send notifications using e-mail.
Code:
Copy Code code as follows:
#!/bin/bash
#
Problems encountered today, how a user such as WWW permissions replicated to my users?
Permissions for the directory representation: dwrxr--r--
Where the first character d represents the directory,-representing the character w is writable, and R
The content of this section:Keep the specified number of files remaining under the file system
Example:
Copy Code code as follows:
#!/bin/bash
#-------------------------------
#Description: Back Up your files
#site: Www.jb51.net
#--
1. Understanding Bash
Through the shell will input the instructions and kernel communication, let kernel control hardware workView Shell:cat/etc/shellA preset shell type is recorded in the/etc/passwd after login and is related to the accountCommand
The security and stability of the server is the goal that every operational dimension wants to achieve, after all, once the site traffic is big, visit high, there will be some boring people to attack, to help detect the loophole is good, but the
We have such a string:
Copy Code code as follows:
info= ' ABCD;EFGH '
Now to get ABCD and efgh, we can simply use the cut tool to get:
Copy Code code as follows:
Fstr= ' echo $info | cut-d \; -F 1 '
Sstr= ' echo $info |
Today, when writing a shell script to find that you need to set the user's password, and set the password is interactive, so in the script is obviously not very good, so the Internet to find data, found the following two common way to set the
To get the absolute path of the executing program/script itself, you can use DirName (Realpath (__file__) in PHP, and C # has System.Windows.Forms.Application.StartupPath; Java does not seem to have any more direct method, can only use Codesource to
You need to find the last position of one of the characters in the string, which is available in PHP (Strrpos) or Perl (Rindex), and you can't think of a way out of the shell. Post on the Forum also no one answer (do not know whether the problem is
Here is a brief description of a bash script that you wrote to detect if a process exists. directly on the code.
Copy Code code as follows:
#!/bin/bash
ps_out= ' Ps-ef | grep $ | Grep-v ' grep ' | Grep-v $ '
result=$ (echo $ps _out |
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.