LoginSignup
1
5

More than 5 years have passed since last update.

Linuxコマンド[ps]

Last updated at Posted at 2017-06-15

 下記のようなエラーが出た場合。
別で正しくrails serverのshutdownが行われずプロセスが残っているために起こる。

[vagrant@vagrant-centos65 railbook]$ rails s
=> Booting WEBrick
=> Rails 4.0.2 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
A server is already running. Check /home/vagrant/rails/railbook/tmp/pids/server. pid.
Exiting

Linuxコマンドにて

ps


  • 実行中のプロセスを表示する。

ps aux


  • a = 自分以外のユーザーのプロセスも表示
  • u = ユーザー名と開始時刻を表示
  • x = 制御端末のないプロセス情報も表示

ps aux | grep rails


  • grepより自身以外のプロセスの表示にする。 よって上記のコードよりrailsの別のプロセスのみを表示できるため、shutdownがきちんと行われていないプロセスを見つけることができる。
[vagrant@vagrant-centos65 railbook]$ ps aux | grep rails
agrant   1332  0.8  7.0 494220 72072 ?        Sl   01:22   0:02 /usr/local/bin/ ruby bin/rails server -d -b 0.0.0.0
vagrant   1373  0.0  0.0   8388   856 pts/0    S+   01:27   0:00 grep rails

今回は1332が残っているプロセス、1373は今実行しようとしているプロセス。

[vagrant@vagrant-centos65 railbook]$ kill 1332

よって上記コマンドより1332をキルする。

[vagrant@vagrant-centos65 railbook]$ ps aux | grep rails
vagrant 1375 0.0 0.0 8388 856 pts/0 S+ 01:27 0:00 grep rails

無事消えました。
これによりrails sから通常通りサーバーを起動可能となる。

※追加
 teratermを再起動しても解決可能。

1
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
5