SHELL: Write NGINX Service Control script, shell: Write nginx script
Nginx installed in the source code package cannot use "service nginx start" or "/etc/init. d/nginx start" for operations and control. Therefore, the following service control script is written.
You can use
/*************************************** ******************************* Author: Samson* Date: 08/01/2013
**************************************** ****************************/
BASH Shell script programming learning summary:
Variable:(1) environment variables: can be modified;(2) internal variables: provided by the system and cannot be modified;$ #: Get the number of parameters$? : ShellProgramReturn
Now we will demonstrate how to use Bash scripts to automatically deploy JDK.
Environment: ubuntu12.04 amd 64 desktop or server, which must be BASH Shell
Copy the directory Java to the target machine and run the install. Sh script with the root permission.
Take a look at the directory structure:
. ── Check. Sh ├ ── install. Sh ├ ── jdk1.6.0 _ 35 ── r
Exercise: Write a scriptDetermine if there is a user's default shell for bash on the current system;If so, the number of such users is displayed, otherwise no such user is shown#!/bin/bashAcount= ' grep ' \If [$acount-gt 0];thenecho "There has $acount such users"Elseecho "No such users"FiExercise: Write a scriptGiven a file, such as/etc/inittabDetermine if there
Save a script file under Windows, upload to CentOS with SSH, add permission to execute Nginx prompt without that file or directory.The shell script is placed in the/etc/init.d/directory, and then executes the/etc/init.d/nginx, prompting more of this sentence/bin/bash^m:bad interpreter.We found the information on the Internet.If the
If you host your own blog or any Web-based application running on the stack, you shoshould have a backup system in place for keeping data stored in MySQL databases safe. there are several solutions that can help you with that, but nothing beats a simple Bash script I stumbled upon in a blog post comment. here is the script in all its beauty:
[If you manage your o
1. Character truncation:If the character truncation is a generic path, you can use both the basename and dirname tools:BaseName can truncate a filename from a file path
For example:
Copy Code code as follows:
$ basename/home/file.tar
File.tar
DirName can be truncated to a directory path from a file path
For example:
Copy Code code as follows:
$ dirname/home/file.tar
/home
Do not use external tools for character truncation
Bash controls the number of concurrent jobs. The script uses bash to control the number of concurrent jobs. 01 #! /Bin/bash02 #0304 CMDS [1] quot; echo $ USER amp; #39; 01 BEGIN amp; #39; amp; sleep6 amp; amp; echo $ USER amp; #39; 01END amp; #39; quo bash controls the number of concurrent tasks. The
The bash script is registered as a service and automatically started upon startup. the chkconfig command is used to update (start or stop) and query the running level information of the system service. Remember that chkconfig does not automatically disable or activate a service immediately, but simply changes the symbolic connection. Use the bash
"/>
One-step execution: Bash-x Script Name
Exercise: enter two integers A and B, where a
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/4D/D3/wKioL1Ra46nTXoqpAABtpClfocc303.jpg "Title =" script 2121.png "alt =" wkiol1ra46ntxoqpaabtpclfocc303.jpg "/>
Now let's take a look at the process.
650) This. width = 650; "src =" http://s3
, warnings, and error messages during a script run are identified with different string prefixes, making them easier to identify.
Based on the above considerations, the script template is created as follows:#!/bin/Bashscript_name=""script_usage=$ (Cat Eofdescription of script usage. EOF) script_function=$ (Cat Eofdescription of scriptfunction. EOF) script_do
Scenario: a csv file containing student details of multiple departments needs to be inserted into a data table to ensure that each department generates a separate ranking list. The data in the studentdatacsv file of the learning information table is as follows: 1, NavinM
Zookeeper
Scenario:There is a csv file containing student details of multiple departments. you need to insert the file content into a data table to ensure that each department generates a separate ranking list.
The data in t
Java calls Bash shell script blocking small problem resolutionBackgroundUsing Java implementation of the Web side, the web side of the corresponding user interface operation, using Java Call Bash implementation of the shell script to do the actual operation, the operation is completed to return the results of execution
This article is an improvement of the shell script of the previous Watchdate Wdate, again first:650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/76/95/wKioL1ZWwy_juP9NAARfY7_6zMo324.jpg "title=" Wdate " alt= "Wkiol1zwwy_jup9naarfy7_6zmo324.jpg"/>1) script Join Chkconfig Management head-5/etc/init.d/wdate#!/bin/bash#auth:[email protected]# #wdate start/s
Script Security
All of my bash scripts start with the following lines:
The code is as follows
Copy Code
#!/bin/bashSet-o NounsetSet-o Errexit
Doing so avoids two common problems:
Reference to an undefined variable (the default value is "")
Commands that failed to execute are ignored
It should be noted that some of the parameters of some Linux commands can be enforc
Bash Script Programming second, conditional judgmentCondition Judgment:If the user does not existAdd user, give password and display add success;OtherwiseShow that the user is already present, not addedHow do I make conditional judgments in bash?Integer testCharacter Test File testExpressions for Conditional tests:[Expression][[Expression]]Test expressionInteger
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.