bash script to start another script in a tmux session

Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I have a bash script that continuously outputs some information when run. I need to
- Automatically run this when my system boots.
- Monitor this output and control it every once in a while remotely, using ssh.
For this purpose, I would like to use tmux. So how do I approach this? For simplicity, let's say my shell script is this:
filename: start.bash
#!/bin/bash
# just an example for simplicity
watch date
I need another script that runs this in tmux and be able to attach to this when I need, later. I am struggling at the part where I need to create a new tmux session with a name and make it run another shell script. Once I have this working, I can put this in another shell script and take care of the rest of the stuff. That is easy, I think. Can someone give me an example for this specific step please?
bash tmux
add a comment |Â
up vote
1
down vote
favorite
I have a bash script that continuously outputs some information when run. I need to
- Automatically run this when my system boots.
- Monitor this output and control it every once in a while remotely, using ssh.
For this purpose, I would like to use tmux. So how do I approach this? For simplicity, let's say my shell script is this:
filename: start.bash
#!/bin/bash
# just an example for simplicity
watch date
I need another script that runs this in tmux and be able to attach to this when I need, later. I am struggling at the part where I need to create a new tmux session with a name and make it run another shell script. Once I have this working, I can put this in another shell script and take care of the rest of the stuff. That is easy, I think. Can someone give me an example for this specific step please?
bash tmux
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have a bash script that continuously outputs some information when run. I need to
- Automatically run this when my system boots.
- Monitor this output and control it every once in a while remotely, using ssh.
For this purpose, I would like to use tmux. So how do I approach this? For simplicity, let's say my shell script is this:
filename: start.bash
#!/bin/bash
# just an example for simplicity
watch date
I need another script that runs this in tmux and be able to attach to this when I need, later. I am struggling at the part where I need to create a new tmux session with a name and make it run another shell script. Once I have this working, I can put this in another shell script and take care of the rest of the stuff. That is easy, I think. Can someone give me an example for this specific step please?
bash tmux
I have a bash script that continuously outputs some information when run. I need to
- Automatically run this when my system boots.
- Monitor this output and control it every once in a while remotely, using ssh.
For this purpose, I would like to use tmux. So how do I approach this? For simplicity, let's say my shell script is this:
filename: start.bash
#!/bin/bash
# just an example for simplicity
watch date
I need another script that runs this in tmux and be able to attach to this when I need, later. I am struggling at the part where I need to create a new tmux session with a name and make it run another shell script. Once I have this working, I can put this in another shell script and take care of the rest of the stuff. That is easy, I think. Can someone give me an example for this specific step please?
bash tmux
asked Dec 15 '17 at 21:02
code4kix
1155
1155
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
2
down vote
accepted
You can do this many ways.
You can do it after you've created the session either with send-keys:
tmux new -s "remote" -d
tmux send-keys -t "remote" "start.bash" C-m
tmux attach -t "remote" -d
Or through the shell:
tmux new -s "remote" -d "/bin/bash"
tmux run-shell -t "remote:0" "start.bash"
tmux attach -t "remote" -d
add a comment |Â
up vote
0
down vote
Start a tmux session on the server and do not close it. It will keep running on the server. From your client computer you will be able to ssh in and run
tmux attach
to reconnect to whatever you had running in the tmux session. To start it at boot time if you reboot the server start tmux from a shell script that runs from /etc/rc.local
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
You can do this many ways.
You can do it after you've created the session either with send-keys:
tmux new -s "remote" -d
tmux send-keys -t "remote" "start.bash" C-m
tmux attach -t "remote" -d
Or through the shell:
tmux new -s "remote" -d "/bin/bash"
tmux run-shell -t "remote:0" "start.bash"
tmux attach -t "remote" -d
add a comment |Â
up vote
2
down vote
accepted
You can do this many ways.
You can do it after you've created the session either with send-keys:
tmux new -s "remote" -d
tmux send-keys -t "remote" "start.bash" C-m
tmux attach -t "remote" -d
Or through the shell:
tmux new -s "remote" -d "/bin/bash"
tmux run-shell -t "remote:0" "start.bash"
tmux attach -t "remote" -d
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
You can do this many ways.
You can do it after you've created the session either with send-keys:
tmux new -s "remote" -d
tmux send-keys -t "remote" "start.bash" C-m
tmux attach -t "remote" -d
Or through the shell:
tmux new -s "remote" -d "/bin/bash"
tmux run-shell -t "remote:0" "start.bash"
tmux attach -t "remote" -d
You can do this many ways.
You can do it after you've created the session either with send-keys:
tmux new -s "remote" -d
tmux send-keys -t "remote" "start.bash" C-m
tmux attach -t "remote" -d
Or through the shell:
tmux new -s "remote" -d "/bin/bash"
tmux run-shell -t "remote:0" "start.bash"
tmux attach -t "remote" -d
answered Dec 15 '17 at 23:38
jdwolf
2,392116
2,392116
add a comment |Â
add a comment |Â
up vote
0
down vote
Start a tmux session on the server and do not close it. It will keep running on the server. From your client computer you will be able to ssh in and run
tmux attach
to reconnect to whatever you had running in the tmux session. To start it at boot time if you reboot the server start tmux from a shell script that runs from /etc/rc.local
add a comment |Â
up vote
0
down vote
Start a tmux session on the server and do not close it. It will keep running on the server. From your client computer you will be able to ssh in and run
tmux attach
to reconnect to whatever you had running in the tmux session. To start it at boot time if you reboot the server start tmux from a shell script that runs from /etc/rc.local
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Start a tmux session on the server and do not close it. It will keep running on the server. From your client computer you will be able to ssh in and run
tmux attach
to reconnect to whatever you had running in the tmux session. To start it at boot time if you reboot the server start tmux from a shell script that runs from /etc/rc.local
Start a tmux session on the server and do not close it. It will keep running on the server. From your client computer you will be able to ssh in and run
tmux attach
to reconnect to whatever you had running in the tmux session. To start it at boot time if you reboot the server start tmux from a shell script that runs from /etc/rc.local
answered Dec 17 '17 at 1:19
tluafed
111
111
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f411141%2fbash-script-to-start-another-script-in-a-tmux-session%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password