0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

tmux でサーバ上でバッチ処理を実行する、そしてそのログファイルをローカルに落とす

Last updated at Posted at 2021-09-23

個人的メモ。rails のバッチ処理の場合を想定。

手順

リモートサーバーにssh接続する。

$ kubectl exec -it <Pod名> /bin/bash
$ apt-get update
$ apt-get install tmux

$ tmux new -s <session名>

# ログを書く出す前に、tmux-logging pluginをinstall
$ mkdir /temp && cd /temp
$ git clone https://github.com/tmux-plugins/tmux-logging ~/temp
$ echo 'run-shell ~/temp/logging.tmux' >> /root/.tmux.conf
$ tmux source-file /root/.tmux.conf

<ctr + b, P> # Started logging to /root/xxxxxx.log と表示される。このファイル名をメモ。
 
# railsディレクトリへ移動。
$ cd /app
$ bundle exec rails runner lib/batch/batch.rb

# ctr + w でターミナルを閉じてOK!

バッチ処理終了後にコンテナからローカルにファイルコピーする。

$ kubectl cp <Pod名>:/root/xxxxxx.log ./local_file.log

Ref

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?