ITPub博客

首页 > Linux操作系统 > Linux操作系统 > [20170708]tmux script例子.txt

[20170708]tmux script例子.txt

原创 Linux操作系统 作者:lfree 时间:2017-07-11 09:24:18 0 删除 编辑

[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博客 ” ,链接:https://blog.itpub.net/267265/viewspace-2141884/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    4006
  • 访问量
    7970129