Linux-related commands for Tomcat services __linux

Source: Internet
Author: User
Tags change settings chmod clear screen memory usage readable system echo
One: Startup, shutdown, and error tracking for Tomcat services under Linux, when you use putty to remotely connect to the server, you typically start the shutdown Tomcat service in several ways:
Switch to the Bin directory (CD Usr/local/tomcat/bin) in the Tomcat home directory
1, start the Tomcat service
Mode one: Direct start./startup.sh

Mode two: start Nohup/startup.sh & As a service (this can result in large nohup.out files)

You can use the Nohup./catalina.sh Run >/dev/null & Start Service


Mode three: the console dynamic output mode is started./catalina.sh Run dynamically displays the console output information in tomcat background, CTRL + C, and then exit and close the service
Explain:
By way of one, mode three boot Tomcat has a disadvantage, when the client connection is disconnected, the Tomcat service will immediately stop, through the way two can be used as Linux services have been running
By means of mode one, the way to start Tomcat, its log will be written to the corresponding log file, and not dynamically view the Tomcat console output information and error conditions, through mode three can be in console mode to start Tomcat service,
directly see the program running the background of the console output information, do not have to be very troublesome every time to open the Catalina.out log file to view, so as to facilitate tracking access to the background output information. The Tomcat console information includes output information such as log4j and System.out.println ().

2, turn off Tomcat service
./shutdown.sh

3,tomcat Runtime JVM Memory allocation
Configuration in MyEclipse under the ⑴ development environment
-xms256m-xmx512m-xx:newsize=64m-xx:maxnewsize=128m-xx:permsize=512m-xx:maxpermsize=512m
⑵, online environment (started directly via Catalina or startup command line)
Under ①linux: catalina.sh
# OS specific support. $var _must_ is set to either True or FALSE. Add the following line after the comment
Java_opts= "-server-xms256m-xmx512m-xx:newsize=64m-xx:maxnewsize=128m-xx:permsize=512m-xx:maxpermsize=512m"
Under ②windows: Cattalina.bat
REM Guess Catalina_home if not defined add the following line after the comment
Set java_opts=-xms256m-xmx512m-xx:newsize=64m-xx:maxnewsize=128m-xx:permsize=512m-xx:maxpermsize=512m

Second: Some common commands under Linux are explained:
1,pwd--> shows the current working directory (pwd:print working directory)
2,ls--> Display current directory contents (list)
Ls|more screen display ("|") For a pipe character, pass the previous command result to the following command, more to indicate a split screen
Ls/usr>test01/abc.txt appends the contents of the specified directory to the Abc.txt text document in the test01 directory
Ls-l display long format, shorthand ll, mainly look at the file name, size, permissions, etc.
Ls-a Show hidden files
3,cd--> change the current working directory
Cd/usr--> go to the specified directory
CD usr--> go to subdirectories of the specified directory
Cd.. --> back to the previous level directory
CD ~--> back to home directory
4,clear--> Clear Screen
5,cat--> Display file contents
Cat File|more Display the contents of the file (first display the contents of the file, and then pass the results to the next command to split the screen)
Cat File|grep ABC Displays the contents of the file containing the character ABC (display the contents of the file first, then pass the result to the last command search, grep has the search function)
Cat > Catalina.out Empty log contents
6,touch--> Create a new file
7,mkdir--> Create a new directory
8,rm--> Delete files or directories
RM file.txt Delete Files
RM-RF test01 Delete a directory that is not empty (parameter R: Recursive recursion,f: Force force)
9,rmdir--> Delete Empty Directory
10,cp--> Copy Files
CP Src.txt Dest.txt
11,mv--> Move Files
MV Abc.txt Def.txt renamed
MV test01 test02 Change directory name
MV test is equivalent to MV t+ (Press the TAB key), the TAB key has the ability to find additional commands.
12,chmod--> Change Permission Mode
chmod +x catalina.sh for catalina.sh plus executable permissions (parameter x: Execute execute). Whether a file under Linux can be executable depends on the file attribute, not the extension.
chmod a+r catalina.out Sets the file catalina.out to be readable by all people. (Parameter A: all)
chmod Ugo+r Catalina.out also sets the file catalina.out to be readable by all people. (Parameter u: File owner User,g:group Group, O:other Other)
A simple editor under the 13,vi-->linux
VI. bash_profile Open Linux User-level initial file,: Wq save exit,: q! do not save exit
14,tail--> display file tail content
Tail-f./catalina.out, #将文件最尾部内容显示在屏幕上, and constantly refresh the display, press CTRL + C or delete to exit.
15,netstat or lsof--> View network port and process number
①netstat-anp|grep 8080 Direct view of process PID for the specified port
#结果为
Protocol local address external address state PID
TCP 0.0.0.0:80 0.0.0.0:8080 Listening 5144/java

②lsof-i:8080 directly view process PID for the specified port
#结果为
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
Java 5144 root 33u IPv6 127800 TCP *:8080 (LISTEN)
Then 5144 is 8080 of this port's Tomcat process PID, and then you can kill the process: Kill-9 5144
Compare Windows netstat command: Netstat-ano|findstr 8080,taskkill-f-pid 5144 (F:force mandatory)
16,ping--> View Network is connected
Ping 127.16.8.66 to see if the current machine and directory machine can communicate properly (mainly to see if the TCP/IP protocol is normal)
17,ipconfig View IP Address
Ipconfig-all can see the IP address and MAC address of each network adapter (local network card, wireless network card)
18,ps--> View program activity process
Ps-ef |grep Tomcat to see if Tomcat is running, and if so, kill the process
#结果为:
Sun 1540 1 0 10:21 pts/1 00:00:06/java/jdk/bin/java-djava.util.logging.manager=org.apache.juli.classloaderlogmanager -djava.endorsed.dirs=/java/tomcat/common/endorsed-classpath:/java/tomcat/bin/bootstrap.jar:/java/tomcat/bin/ commons-logging-api.jar-dcatalina.base=/java/tomcat-dcatalina.home=/java/tomcat-djava.io.tmpdir=/java/tomcat/ Temp Org.apache.catalina.startup.Bootstrap Start
Then 1540 is the process number PID = 1540, and then you can kill the process: Kill-9 1540
Compare Windows tasklist command: tasklist | findstr tomcat,taskkill-f-pid 5144
19,telnet--> test whether the remote port is connected
Telnet 10.4.200.114 1433
The ① port unobstructed condition
Trying 10.4.200.114 ...
Connected to 10.4.200.114 (10.4.200.114).
Escape character is ' ^] '.
② Port does not pass
Trying 10.4.200.114 ...
If you can ping, but the port is not, indicating that the firewall may be disabled by the port, the solution:
Linux: View firewall: Iptables–l
Immediate effect, reboot failure (open: Service iptables start, close: Service iptables stop)
Setting up a firewall: Setup (garbled) Resolve Putty tool garbled: View the character set used in the Linux system echo $LANG $LANGUAGE, select the menu modification settings (change settings)---> Transform (translation)-- > Selected utf-8--> application (apply)
Win7 Firewall Open port method: Control Panel-System and security---Windows Firewall---Advanced settings-inbound rules-new rule--> add 1433 ports.
20,DF--> View disk space (Diskfree)
Df-lh/usr/local
21,du--> View used space (diskused)
Du-h/usr
Du-h--max-depth=1 View folder size
22,top-->linux's commonly used performance analysis tools enable real-time display of resource consumption for each process in the system, similar to Windows Task Manager
Top-s View Memory usage
Top-s | grep Java View information for Java processes

23,linux Compression and decompression
1,tar.gz This format is the most used compression format under Linux. It does not take up too much CPU during compression and can get a very desirable compression rate.
TAR-ZCVF archive_name.tar.gz directory_to_compress--> compresses a directory
TAR-ZXVF archive_name.tar.gz--> extract to current directory
TAR-ZXVF archive_name.tar.gz-c/usr/temp/--> extracted to the specified directory
Parameter explanation:
-z-gzip call gzip To further compress the tar archive into the tar.gz format, or to extract the tar.gz format
-x-extract to extract archived specified (or all) files
-c-create Create a new archive
-v-verbose Generate verbose output
-f-file Specify archive file name
-R appending files to the end of the archive file
-C Change Directory

2, compression/decompression ZIP format
Zip file.zip./directory/*--> compresses all files and directories in the specified directory
Unzip file.zip-d./test--> extracted to the specified directory
Unzip File.zip--> uncompressed to current directory
Unzip-v Largefile.zip--> Only view the contents of the compressed package and do not understand the compression

Three: Linux and Windows a few differences:
Echo $PATH to echo the value of the Linux environment variable PATH, the environment variables under Linux must be capitalized
Echo%path% echoes the value of the Windows environment variable path

Export Path=/usr/local/tomcat Modify Set the Linux environment variable path value (temporary), Linux file system path is a slash
Set Path=d:\program Files\tomcat modifies the value of path of the Windows environment variable (temporary), and the Windows file system path is a backslash

Linux: View, modify the user-level initial file (. bash_profile) under Linux, which is a hidden file (permanent)
Windows: Computer--> Properties--> Advanced--> environment variables, viewing, modifying environment variables (permanent)

Linux command Search with grep, for example netstat-anp|grep 8080
Windows DOS command search uses findstr, such as NETSTAT-ANP|FINDSTR 8080

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.