简体   繁体   English

重启进程脚本 linux

[英]Restart process script linux

Can anyone helps me with a script which find process id by name and then restart it?任何人都可以帮助我使用按名称查找进程 ID 然后重新启动它的脚本吗?

pidof PROG_NAME | xargs kill -9 ; PROG_NAME

kills every instance of PROG_NAME and restarts an instance (if PROG_NAME is in your PATH)杀死 PROG_NAME 的每个实例并重新启动实例(如果 PROG_NAME 在您的 PATH 中)

it's depends expecting/prefer behavior, i'm use this inside script:这取决于期望/偏好行为,我在脚本中使用它:

killall $1 && $1 &杀死所有 $1 && $1 &

(it's not load new instance if/before current not closed properly) (如果/之前当前未正确关闭,则不会加载新实例)

then binding it to alias in ~/.bashrc:然后将它绑定到 ~/.bashrc 中的别名:

alias rld='/path_to_script/script.sh'别名 rld='/path_to_script/script.sh'

then just (in console):然后只是(在控制台中):

rld process_name rld 进程名称

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM