根据进程名杀死进程 -kill -9 $(pidof 进程名关键字)

参考:https://blog.csdn.net/zhaoyue007101/article/details/7699259

#kill -9 $(ps -ef|grep 进程名关键字|gawk '$0 !~/grep/ {print $2}' |tr -s '\n' ' ')

在开发平台上ps -ef不支持,执行项只有

# ps -ef
ps: invalid option -- 'e'
BusyBox v1.23.2 (2016-11-15 23:14:33 CST) multi-call binary.

Usage: ps 

Show list of processes

        w       Wide output
        l       Long output
        T       Show threads


修改字段:

ps -l | grep jarves | awk '$0 !~/grep/ {print $2}' |tr -s '\n' ' '

ps -l | grep jarves  
S     0  7414   520  3576   400 ttyS0 01:31 00:00:00 grep jarves

# ps -w | grep jarves
  779 root      250m S    {MSystem::Run} /applications/bin/jarves
 9367 root      3576 S    grep jarves
 
# ps -w | grep jarves | awk '$0 !~/grep/ {print $1}'
779

然后可以用:

kill -9 $(ps -w | grep jarves | awk '$0 !~/grep/ {print $1}')

这个是利用管道和替换将 进程名对应的进程号提出来作为kill的参数。很显然上面的方法能完成但是过于复杂,

下面这种就显得简单的多了
2、#kill -9 $(pidof 进程名关键字)

kill -9 $(pidof jarves)

 

附录:

linux signals

Signal NameNumberDescription
SIGHUP1Hangup (POSIX)
SIGINT2Terminal interrupt (ANSI)
SIGQUIT3Terminal quit (POSIX)
SIGILL4Illegal instruction (ANSI)
SIGTRAP5Trace trap (POSIX)
SIGIOT6IOT Trap (4.2 BSD)
SIGBUS7BUS error (4.2 BSD)
SIGFPE8Floating point exception (ANSI)
SIGKILL9Kill(can't be caught or ignored) (POSIX)
SIGUSR110User defined signal 1 (POSIX)
SIGSEGV11Invalid memory segment access (ANSI)
SIGUSR212User defined signal 2 (POSIX)
SIGPIPE13Write on a pipe with no reader, Broken pipe (POSIX)
SIGALRM14Alarm clock (POSIX)
SIGTERM15Termination (ANSI)
SIGSTKFLT16Stack fault
SIGCHLD17Child process has stopped or exited, changed (POSIX)
SIGCONT18Continue executing, if stopped (POSIX)
SIGSTOP19Stop executing(can't be caught or ignored) (POSIX)
SIGTSTP20Terminal stop signal (POSIX)
SIGTTIN21Background process trying to read, from TTY (POSIX)
SIGTTOU22Background process trying to write, to TTY (POSIX)
SIGURG23Urgent condition on socket (4.2 BSD)
SIGXCPU24CPU limit exceeded (4.2 BSD)
SIGXFSZ25File size limit exceeded (4.2 BSD)
SIGVTALRM26Virtual alarm clock (4.2 BSD)
SIGPROF27Profiling alarm clock (4.2 BSD)
SIGWINCH28Window size change (4.3 BSD, Sun)
SIGIO29I/O now possible (4.2 BSD)
SIGPWR30Power failure restart (System V)
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页