http://blog.csdn.net/pipisorry/article/details/23376005
Job Management Job Control
When you log in to bash, you want to copy files, search for data, compile on one side, and write vim programs while you're on the go! Of course we can repeatedly log in to the six command-line terminal environment, but can also be reached within a bash.
The management of job control throws instructions directly into the background of "execute" & throws "current" work into the background "pause": [Ctrl]-z
[1]+ Stopped Vim ~/.BASHRC
In the general mode of VIM, pressing [Ctrl] and Z buttons will appear on the screen [1], indicating that this is the first job, and that the + represents the most recent job thrown into the background, and currently in the context of the default will be taken out of the work (FG this command)! And that Stopped represents the current state of the job. By default, work that is thrown into the background using [Ctrl]-z] is a "paused" state Oh!
Observe the current background work status: Jobs
# jobs [-lrs] options and Parameters: -L: In addition to listing the job number and instruction string, the PID numbers are listed at the same time;-R : Lists only the work that is running on the background;-S : Lists only the work that is paused (stop) in the background.
Get background work to the foreground: FG
# FG%jobnumber Options and Parameters:%jobnumber:jobnumber is the work number (number). Note that the percent is optional!
Let the work in the background turn into a running state: BG
# jobs; BG%3; Jobs
Work in the management context: Kill
# kill-signal%jobnumber[[email protected] ~]# kill-l options and Parameters:-L : This is the lowercase of L, which lists the current signals (signal) that kill can use? Signal: What kind of instructions do you give to the job at the back? With Man 7 signal know: -1: Re-read the parameter configuration file (similar to reload); -2: Represents the same action as input by the keyboard [Ctrl]-c; -9: Forcibly delete a job immediately; -15: with normal procedures Way to terminate a work. And-9 are not the same.
# kill-9% 2; Jobs
Note: 9 This signal is usually used when "forced removal of an unhealthy job", and 15 is the end of a work with normal steps (15 is also the default value), which is not the same! For the above example, when I use VIM, does it produce a. filename.swp file? Then, when using the-15 signal, VIM will attempt to end the work of the VI in a normal step, so. FILENAME.SWP will be removed on its own initiative. However, if you use the 9 signal, the VIM will be forcibly removed, so the. FILENAME.SWP will continue to exist in the file system.
Offline management \ Offline Management The "background" referred to in the work management refers to a situation where the crtl]-c interrupt can be avoided in terminal mode, which is the background of bash, not the background of the system! So, the background of work management is still related to the terminal! If you are connecting to your Linux host with a remote connection (such as SSH), and you put your work into the background in &, you are offline when the work is not over, and the work will not continue, but will be interrupted.
First, you can use at to handle! Because at is to place work on the system background and not on the terminal.
You can also use the Nohup
The general form of the command is: Nohup Command &
# nohup [instructions and parameters] #在终端机前景中工作 # nohup [directives and parameters] & #在终端机背景中工作
Note:nohup does not support bash's built-in instructions, so your instructions must be external.
You can use top or pstree to see if the command you just ran is in the background.
Nohup command and its output file
Nohup command: If you are running a process and you feel that the process will not end when you exit the account, you can use the Nohup command. This command can continue to run the process after you exit the account/close the terminal. Nohup is the meaning of not hanging (n ohang up). Submit a job using the Nohup command if the job is submitted with the Nohup command, all output of the job is redirected to a file named Nohup.out by default, unless an output file is specified: (that is, the file name of the custom output) Nohup command > Myout.file 2>&1 & In the example above, the output is redirected to the Myout.file file. Use jobs to view tasks. Use FG%n to close.
Note:
1 If you run nohup each time, and then enter other commands will [1]+ Exit 1, stating that the program error, first run directly or redirect 2 > Error.txt to see what the error is.
2 output hint nohup:ignoring input and appending output to ' nohup.out '
That's not a error-it ' s normal behavior. It just informs you once started the in/output are removed from your console. Do not want to output, redirect on it.
There are also two commonly used FTP tools Ncftpget and Ncftpput, can be implemented in the background FTP upload and download, so I can use these commands in the background to upload and download files.
[Resolves a program or service that runs after the Linux shutdown terminal (SSH, etc.) automatically stops the "background run Program"]
Phi Blog
Process Management
Observation of the program
PS (ps-l, PS aux, zombie), Top, Pstree
View memory footprint and CPU usage top
# top [-d 数字] | top [-bnp]选项与参数:-d :后面可以接秒数,就是整个程序画面更新的秒数。默认是 5 秒;-b :以批次的方式执行 top ,还有更多的参数可以使用喔! 通常会搭配数据流重导向来将批次的结果输出成为文件。-n :与 -b 搭配,意义是,需要进行几次 top 的输出结果。-p :指定某些个 PID 来进行观察监测而已。在 top 执行过程当中可以使用的按键指令: ? :显示在 top 当中可以输入的按键指令; P :以 CPU 的使用资源排序显示; M :以 Memory 的使用资源排序显示; N :以 PID 来排序喔! T :由该 Process 使用的 CPU 时间累积 (TIME+) 排序。 k :给予某个 PID 一个讯号 (signal) r :给予某个 PID 重新制订一个 nice 值。 q :离开 top 软件的按键。
The contents of the display are:
First line (Top ... ): This line shows the following information:
- The current time, that is, 00:53:59 that project;
- The time elapsed so far, that is, up 6:07, the project;
- The number of users who have logged into the system, that is, 3 users, the project;
- The system averages the workload at 1, 5, 15 minutes. The batch mode we talked about in chapter 15th is the load of less than 0.8. On behalf of 1, 5, 15 minutes, the system average is responsible for running several programs (work) meaning. The smaller the system, the more idle, if more than 1 should pay attention to your system program is too complicated!
Second row (Tasks ...) ): Shows the total amount of the current program in what state (running, sleeping, stopped, zombie) the individual program is in. The comparison needs to be noted is the last zombie that value, if not 0! Take a good look at that process and become a zombie, right?
Third line (%cpus ... ): Displays the overall CPU load, which can be used per project? Inspection. Special attention to the WA project, that project represents I/O wait, usually your system will be slow is the problem of I/O is relatively large! So it's important to note that this project consumes CPU resources. In addition, if the device is multi-core, you can press the number key "1" to switch to different CPU load rate.
Row four and line fifth: represents the current use of entity memory and virtual memory (MEM/SWAP). Again, it is important to note that the use of swap should be as small as possible! If swap is used a lot, it means that the system's physical memory is not enough!
Line six: This is where the state is displayed when the command is entered in the top program.
For the top lower half of the screen, it is the resource situation used by each process. The comparison needs to be noted:
- PID: ID of each process!
- User: The user to whom the process belongs;
- Pr:priority, the priority order of the program, the smaller the sooner it is executed;
- The abbreviation of Ni:nice, which is related to priority, is also smaller and sooner executed;
- %cpu:cpu of the use rate;
- %MEM: Memory utilization;
- Time+:cpu the use of the time accumulation;
command to view memory usage separately: free-m
commands for viewing memory and CPU usage: Top
You can also install the Htop tool, which is more intuitive,
The installation commands are as follows: sudo apt-get install htop
After installation, enter the command directly: Htop
Phi Blog
Management of the program
Signal, Kill, Killall
Phi Blog
Order of execution of the program
Priority, Nice, Renice
Phi Blog
View of system resources
Free, uname, uptime, netstat, DMESG, vmstat
System
# uname-a # View kernel/Os/cpu information
# head-n 1/etc/issue # view OS version
# cat/proc/cpuinfo # View CPU Information
# hostname # View computer name
# LSPCI-TV # list all PCI devices
# LSUSB-TV # list all USB devices
# lsmod # List of loaded kernel modules
# env # View Environment variables
View CPU information (model number)
# Cat/proc/cpuinfo | grep name | Cut-f2-d: | Uniq-c
8 Intel (R) Xeon (r) CPU E5410 @ 2.33GHz
(see 8 logical CPUs, also know the CPU model)
# Cat/proc/cpuinfo | grep Physical | Uniq-c
4 Physical id:0
4 Physical Id:1
(Description is actually two 4-core CPUs)
# getconf Long_bit
32
(indicates that the current CPU is running in 32bit mode, but does not mean that the CPU does not support 64bit)
# Cat/proc/cpuinfo | grep Flags | grep ' LM ' | Wc-l
8
(The result is greater than 0, indicating support for 64bit calculations. LM refers to long mode, which supports LM is 64bit)
Look at the CPU details in full, but most of us don't care.
# Dmidecode | grep ' Processor information '
View memory Information
# Cat/proc/meminfo
# uname-a
Linux euis1 2.6.9-55.ELSMP #1 SMP Fri April 17:03:35 EDT i686 i686 i386 gnu/linux
(view current operating system kernel information)
# Cat/etc/issue | grep Linux
Red Hat Enterprise Linux as Release 4 (Nahant Update 5)
(View current operating system release information)
View Machine Model
# Dmidecode | grep "Product Name"
viewing network card information
# DMESG | Grep-i ETH
Resources
# free-m # View memory usage and swap area usage
# df-h # View the usage of each partition
# du-sh < directory name > # View the size of the specified directory
# grep Memtotal/proc/meminfo # View Total Memory
# grep Memfree/proc/meminfo # View the amount of free memory
# uptime # View System uptime, number of users, load
# cat/proc/loadavg # View System load
Disks and partitions
# Mount | COLUMN-T # Viewing the status of a mounted partition
# fdisk-l # View all partitions
# swapon-s # View all swap partitions
# hdparm-i/dev/hda # View disk parameters (for IDE devices only)
# DMESG | grep IDE # View IDE device detection status at startup
Internet
# ifconfig # View the properties of all network interfaces
The Linux shell gets the native IP command:
Ifconfig | grep ' inet addr: ' | Grep-v ' 127.0.0.1 ' | Cut-d:-F 2 | awk ' {print '} '
or Ifconfig | grep ' inet addr: ' | Grep-v ' 127.0.0.1 ' | Cut-d:-F 2 | Cut-d '-F 1
or/sbin/ifconfig-a|grep inet|grep-v 127.0.0.1|grep-v Inet6|awk ' {print $} ' |tr-d ' addr: '
or local_host= "' hostname--fqdn '"; Local_ip= ' host $local _host 2>/dev/null | awk ' {print $NF} '
or local_host= "' hostname--fqdn '"; Nslookup-sil $local _host 2>/dev/null | grep Address: | Sed ' 1d ' | Sed ' s/address://g '
[Detailed shell script to get the current IP address]
# iptables-l # View firewall settings
# route-n # View the routing table
# netstat-lntp # View all listening ports
# NETSTAT-ANTP # View all established connections
# netstat-s # View Network statistics
Process
# ps-ef # View All Processes
# top # Real-time display of process status
User
# w # View active Users
# ID < user name > # view specified user information
# last # View user log in log
# cut-d:-f1/etc/passwd # View All users of the system
# cut-d:-f1/etc/group # View all system groups
# crontab-l # View Current user's scheduled tasks
Service
# chkconfig--list # list all system services
# chkconfig--list | grep on # Lists all startup system services
Program
# rpm-qa # View all installed Packages
[Linux View CPU information, machine model, memory and other information]
from:http://blog.csdn.net/pipisorry/article/details/23376005
Ref
Linux Process Management and SELinux