Dowemo
0 0 0 0

This article is primarily a command related to a common linux process in work:

  • System memory viewing free -h, version view lsb_release -a, linux/32, 64 view, timestamp to datetime
  • Lsof based on the port killing process
  • Nohup, the top commonly used ( see the process of specifying users, process kill )

Sys related

Lsb_release -a
Brad -a for all information regarding the kernel version,
Cat/proc/meminfo

This will convert any kB lines to MB:(以MB方式查看内存)awk '$3=="kB"{$2=$2/1024;$3="MB"} 1'/proc/meminfo | column -tThis version converts to gigabytes:(以GB方式查看内存)awk '$3=="kB"{$2=$2/1024**2;$3="GB";} 1'/proc/meminfo | column -tFor completeness, this will convert to MB or GB as appropriate:(以MB/GB方式查看内存)awk '$3=="kB"{if ($2>1024**2){$2=$2/1024**2;$3="GB";} else if ($2>1024){$2=$2/1024;$3="MB";}

The following example

这里写图片描述

这里写图片描述
这里写图片描述

这里写图片描述

Display timestamp as specific time ( without running code direct command view )

timestamp to datetimedate -d @1278999698 +'%Y-%m-%d %H:%M:%S' Where thenumberbehind @ isisthenumberin seconds 

这里写图片描述

Lsof based on the port killing process

General thrift uses more than the port number to kill the process

 sudo lsof -t-i:9001 
 sudo kill $(sudo lsof -t-i:9001) //kill the process fuser -n tcp -k9001//kill the process

Xargs ps, top commonly ( see the process of specifying user, process kill )

Nohub run process background ( nohub, when we execute python demo. Py in a terminal such as SecureCRT, will exit when the current session ends ).
In order to allow the program to not exit normally using nohub

nohub (run processasa background process)
eg1. nohup./yourscript &
eg2. nohup python main.py & 

Ps top view the process of specifying user
Ps -f -u username
Top -u username
这里写图片描述

这里写图片描述

Normally in the shell script, such as our, we'll first kill the original process, and in the run new process general ps -ef | grep processname |.
The following is a bit more concise:
Ps -ef | grep & [ p ] rocessname '

这里写图片描述

Normally kill all processes.

 ps -ef | grep"$1" | awk '{print $2}' | xargs kill -9

In particular, you can see a shell script that monitors the process and restarts the process in another bolg




Copyright © 2011 Dowemo All rights reserved.    Creative Commons   AboutUs