📄 kill-process.sh
字号:
#!/bin/bash# kill-process.shNOPROCESS=2process=xxxyyyzzz # Use nonexistent process.# For demo purposes only...# ... don't want to actually kill any actual process with this script.## If, for example, you wanted to use this script to logoff the Internet,# process=pppdt=`pidof $process` # Find pid (process id) of $process.# The pid is needed by 'kill' (can't 'kill' by program name).if [ -z "$t" ] # If process not present, 'pidof' returns null.then echo "Process $process was not running." echo "Nothing killed." exit $NOPROCESSfi kill $t # May need 'kill -9' for stubborn process.# Need a check here to see if process allowed itself to be killed.# Perhaps another " t=`pidof $process` " or ...# This entire script could be replaced by# kill $(pidof -x process_name)# but it would not be as instructive.exit 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -