Skip to content

Instantly share code, notes, and snippets.

@shadowbq
Last active August 29, 2015 14:24
Show Gist options
  • Save shadowbq/01987b0d01194ab5fa74 to your computer and use it in GitHub Desktop.
Save shadowbq/01987b0d01194ab5fa74 to your computer and use it in GitHub Desktop.
find and kill all old worker.rb and restart in context
#!/bin/sh
# Ubuntu tested 14.04.2
# root@downloader:/usr/local/www/ydl# ps -U www-data -u www-data ajf |grep 'worker.rb' |grep -v 'grep'
# 1 10193 10185 1320 pts/0 10440 Sl 33 0:00 ruby ./worker.rb
# 1 10163 10155 1320 pts/0 10440 Sl 33 0:00 ruby ./worker.rb
echo 'killing old proc'
ps -U www-data -u www-data ajf |grep 'worker.rb' |grep -v grep | awk -F ' ' '{print $3}'| xargs -I {} kill -9 -{}
echo 'starting worker'
sudo -u www-data sh -c 'nohup ./worker.rb >> logs/worker.log &'
echo 'done.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment