Linux shell script execution jar file

Source: Internet
Author: User

Recently engaged in a shell script to start the jar file with a close jar file. I've got a sore egg. It's finally done this evening.

In other words, little brother's Linux is just getting started, after all the information has finally been checked. Not much to say, below the beginning of the shell script written by the younger brother

It's a shell script written by my little brother. Please forgive me for not writing well.

First encounter the first pit

I wrote under window and then the Linux implementation, in Linux anyway said my 19 line has a mistake, I do not understand, where the wrong, ask someone else, also say yes. Suddenly an expert asked me where I wrote, the younger brother answered in win, he told me to execute the following command:

Dos2unix server.sh

Then the younger brother executed, said the command does not exist, the younger brother had to install this, executed the following command

Yum Install Dos2unix

When he's done, the little brother is executing Dos2unix server.sh.
Then in the Execute. server.sh start,

He could have been a miracle.

The younger brother asked what is the reason. Others tall people, silently answered the sentence, win under the line with Linux is not the same. Younger brother Caishuxueqian, intelligent silently to help degree Niang.

Let me find out this saying:

Linux is not the same as windows and line break. Under Windows is CRLF (\ r \ n or 0d0a), and Linux is LF (\ n or 0a). Under Linux, sometimes you will encounter text files coming from Windows, which have Windows line breaks, and there may be some inexplicable errors in scripting under Linux. Therefore, these files need to be converted to a Linux line break.

Then somebody else's man used other methods. Specific links can be seen under the http://blog.chinaunix.net/uid-20726500-id-4492875.html
Then I was ecstatic, and finally I could.

However when I perform the Stop method there is a pit.

cannot be executed at all, there are the following:

He actually said that this ID did not find, younger brother at that time no language, is he did not find to kill this process ID, have this conjecture, the younger brother resolutely executed the following command:

Little brother, at that time stunned, this command executes out what is AH. Kill command is generally kill-9 (of course this is forced to kill) PID AH this is not AH should be kill-9 1556, think of this I should get is 1556 this PID, how to get it. Brother again please out of our great Niang, search for some, finally let me find this command:

Netstat-anp|grep 9997|awk ' {printf $7} ' |cut-d/-f1, as follows

This value, is what I want to, decisively changed the 7th line of the order, changed to this. I'll just use vim to change my little brother.

Then Wq save, and here's a look at kill off?

The server.sh Stop command is then executed and output on the console

See this, it should be kill off.

It's done.

Then this gets the PID command, the younger brother still does not quite understand awk is what ghost? Cut knows what it means.

And then the magic of the degree Niang. Multi-party snooping, search, the younger brother found this

Awk is a powerful text analysis tool, with the search for grep and the editing of SED, which is especially powerful when it comes to analyzing data and generating reports. To put it simply, awk reads the file one line at a time, using a blank space as the default delimiter to slice each row, and then perform various analytical processes for the cut-off section, see below
Http://www.cnblogs.com/ggjucheng/archive/2013/01/13/2858470.html

Through this link in general also understand

It's got an explanation on it.
In addition, the $ variable refers to the entire record. $ $ represents the first field of the current row, which is the second field of the current row,...... And so on

The little brother has this awk ' {printf $7} '

So what is the meaning of this $7, is to take the 1556/java this value, do not believe that their subordinates are not the seventh one.

So if you find this how to take 1556, if it is in Java, PHP, JS is very easy, but in Linux, then need Cut command, cut as the name implies, I do not explain more,

For specific usage, refer to the following article

Http://www.cnblogs.com/dong008259/archive/2011/12/09/2282679.html

He has a-D is a custom delimiter, then you can cut-d/

It means that the split in JS is about the same.
And then I'll take the first one.

The sum up is cut-d/-F 1
This value is taken.

Through this, the younger brother did learn a lot, but also understand the level of the younger brother Linux.

Linux shell script execution jar file

Related Article

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.