Last active
November 23, 2015 18:30
-
-
Save spalenza/7fd094ca5fe0a8ff51f8 to your computer and use it in GitHub Desktop.
kill process of specifies screen
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
killRailsCScreen() { | |
screen_id=`screen -ls | grep $1 | cut -d'.' -f1 | awk '{print $1}'` | |
if [ ! -z "$screen_id" -a "$screen_id" != " " ]; then | |
rails_id=`ps elax | grep $screen_id | grep '[r]ails c' | awk '{print $3}'` | |
if [ ! -z "$rails_id" -a "$rails_id" != " " ]; then | |
`kill -9 $rails_id` | |
return 0 | |
else | |
echo 'rails c process not found' | |
return 1 | |
fi | |
else | |
echo 'screen no found' | |
return 1 | |
fi | |
} | |
alias kill-rails-c-screen=killRailsCScreen |
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
$ screen -ls | |
There are screens on: | |
30934.spalenza (Detached) | |
30475.rodolfo (Detached) | |
$ ps elax | grep ID_DA_SESSION | grep rails | awk '{print $3}' | |
30107 | |
$ kill -9 30107 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
reference