Created
July 13, 2018 05:51
-
-
Save Petelin/e42260c1fa7c534a7ad8fd3efb8b8300 to your computer and use it in GitHub Desktop.
two greate tool to start proc, or kill proc by name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 # search and kill | |
32 function gkill(){ | |
31 filter=$1 | |
30 exp=[${filter:0:1}]${filter:1} | |
29 echo '>ps aux | grep' $exp | |
28 echo $( ps aux | grep $exp --color=always | xargs -I % echo '\n' %) | |
27 echo "Kill?" | |
26 read Keypress | |
25 case "$Keypress" in | |
24 * ) kill $2 $args $(ps aux | grep $exp --color=always | awk '{print $2}'); | |
23 esac | |
22 } | |
21 | |
20 | |
19 # run a job in screen backgroud | |
18 function jobstart(){ | |
17 name=$1 | |
16 echo "screen -dmS $name bash -c "$2"" | |
15 screen -dmS $name bash -c "$2" | |
14 } | |
13 # send ctrl-c to a screen | |
12 function jobstop(){ | |
11 name=$1 | |
10 echo "screen -S $1 -p 0 -X stuff $'\003'" | |
9 screen -S $1 -p 0 -X stuff $'\003' | |
8 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment