如何编写 shell 脚本以编程方式杀死进程?
我一直在使用以下方法手动终止进程
ps -ef | grep process
kill -9 process id of process
start the process again
但我认为如何以编程方式执行此操作,就像在 shellscript 中写入一样 我只需要运行例如 ./restartProcess.sh
谢谢
I have been using the following way to kill a process manually
ps -ef | grep process
kill -9 process id of process
start the process again
But i think how to do it programmitically as in write in a shellscript
i just have to run e.g. ./restartProcess.sh
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用编辑器创建一个名为restartProcess.sh的文件,
将上述内容放入其中,然后chmod +x restartProcess.sh
几点 -
只需使用kill pid,如果写得相当好,这允许进程清理。
是脚本前两行的Solaris 版本。
use an editor to create a file named restartProcess.sh
Put the above in it, then chmod +x restartProcess.sh
several points -
Just use kill pid, this allows the process to cleanup if it was written reasonably well.
is the solaris version of the first two lines of your script.