[20170708]tmux script例子.txt

lfree發表於2017-07-11

[20170708]tmux script例子.txt

--//上個星期解決rac ora-12514問題時,因為要開啟多個視窗,非常麻煩,利用星期6,7看了一些文件,寫一個tmux script:
--//便於以後工作需要:

#! /bin/bash
tmux has-session -t oracle
if [ $? != 0 ]; then
  tmux new-session -s oracle -d
  tmux new-window -n bashgrid -t oracle
  tmux new-window -n bashoracle -t oracle
  tmux send-keys -t oracle:2 'su - grid' C-m
  tmux send-keys -t oracle:3 'su - oracle' C-m
  tmux select-window -t oracle:1
fi
tmux attach -t oracle

--//也可以這樣寫:
#! /bin/bash
tmux has-session -t oracle
if [ $? != 0 ]; then
  tmux new-session -s oracle -d
  tmux new-window -n bashgrid -t oracle 'su - grid'
  tmux new-window -n bashoracle -t oracle 'su - oracle'
  tmux select-window -t oracle:1
fi
tmux attach -t oracle

--//還可以利用配置檔案來實現例子:

source-file /etc/tmux.conf
new-session -s oracle -d
new-window -n bashgrid -t oracle "su - grid"
new-window -n bashoracle -t oracle "su - oracle"
#new-window -n bashgrid -t oracle
#new-window -n bashoracle -t oracle
#send-keys -t oracle:2 'su - grid' C-m
#send-keys -t oracle:3 'su - oracle' C-m
select-window -t oracle:1

--//使用配置檔案啟動必須後面有引數attach.例子:
tmux -f tmuxoracle.conf attach

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2141884/,如需轉載,請註明出處,否則將追究法律責任。

相關文章