[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