Skip to content

Instantly share code, notes, and snippets.

@spalenza
Last active November 23, 2015 18:30
Show Gist options
  • Save spalenza/7fd094ca5fe0a8ff51f8 to your computer and use it in GitHub Desktop.
Save spalenza/7fd094ca5fe0a8ff51f8 to your computer and use it in GitHub Desktop.
kill process of specifies screen
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
$ 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
@spalenza
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment