小编use*_*345的帖子

杀死:SIGSTOP:bash 脚本中的无效信号规范错误

当我kill在命令行上使用时,它可以工作。

kill -SIGSTOP 1234
Run Code Online (Sandbox Code Playgroud)

但是如果我在 bash 脚本文件中使用,我会收到这个错误:

kill: SIGSTOP: invalid signal specification
Run Code Online (Sandbox Code Playgroud)

.sh 文件是

#!/bin/sh
kill -SIGSTOP 1234
Run Code Online (Sandbox Code Playgroud)

如何kill在 bash 脚本中使用?我试过这个:

#!/bin/sh
/bin/bash -c "kill -SIGSTOP 1234"
Run Code Online (Sandbox Code Playgroud)

但它不起作用。

command-line bash kill

13
推荐指数
2
解决办法
2万
查看次数

如何格式化shell命令的输出

我结合toppidof命令:

top -p $(pidof <process_name>)
Run Code Online (Sandbox Code Playgroud)

如果pidof <process_name>返回一个 idtop命令有效。但是如果pidof <process_name>不止一个 idstop命令不起作用。

pidof 返回 ID 之间有一个空格,例如: 123 124 125

如果我可以用逗号之类的123, 124, 125 top命令获取这些 id就可以了。如何更改 的输出格式pidof

我知道awk用于格式化文本数据。但是我找不到如何awk用于 shell 命令的结果。

shell top pidof

1
推荐指数
1
解决办法
2675
查看次数

标签 统计

bash ×1

command-line ×1

kill ×1

pidof ×1

shell ×1

top ×1