Bash 如何制作一个简单的shell脚本来检查系统是否有一个具有指定名称的进程?
这几乎是一个脚本,用于检查系统是否具有指定名称的进程。如果它确实找到了任何一个进程,它会杀死所有进程,并报告有多少进程被终止,否则它会回显不存在这样的进程 例如: $terminateProcess[正在运行的cpp程序] 应该杀死所有[给定文件名]进程Bash 如何制作一个简单的shell脚本来检查系统是否有一个具有指定名称的进程?,bash,shell,operating-system,Bash,Shell,Operating System,这几乎是一个脚本,用于检查系统是否具有指定名称的进程。如果它确实找到了任何一个进程,它会杀死所有进程,并报告有多少进程被终止,否则它会回显不存在这样的进程 例如: $terminateProcess[正在运行的cpp程序] 应该杀死所有[给定文件名]进程 任何人都能让我开始吗?无需编写shell脚本,pkill已经存在多年了。曼吉尔: pkill will send the specified signal (by default SIGTERM) to each p
任何人都能让我开始吗?无需编写shell脚本,pkill已经存在多年了。曼吉尔:
pkill will send the specified signal (by default SIGTERM) to each
process instead of listing them on stdout.
-c, --count
Suppress normal output; instead print a count of matching pro‐
cesses. When count does not match anything, e.g. returns zero,
the command will return non-zero value.
Example 2: Make syslog reread its configuration file:
$ pkill -HUP syslogd
在开始编写自己的程序之前,您应该检查这样的程序是否已经存在。然后,您将找到
pkill
,从而节省一些精力。