× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Write a shell script that starts tmux session and then runs a ruby script inside the session

<p><span style="background-color:rgb(255, 255, 255); color:rgb(34, 34, 34)">1. Create a file named </span><code>my_script.sh</code><span style="background-color:rgb(255, 255, 255); color:rgb(34, 34, 34)"> and give it the following contents:</span></p> <pre><code><span style="color:rgb(128, 128, 128)">#!/bin/bash</span><span style="color:rgb(0, 0, 0)"> tmux </span><span style="color:rgb(0, 0, 139)">new</span><span style="color:rgb(0, 0, 0)">-</span><span style="color:rgb(0, 0, 0)">session </span><span style="color:rgb(0, 0, 0)">-</span><span style="color:rgb(0, 0, 0)">d </span><span style="color:rgb(0, 0, 0)">-</span><span style="color:rgb(0, 0, 0)">s my_session </span><span style="color:rgb(128, 0, 0)">'ruby run.rb'</span><span style="color:rgb(0, 0, 0)"> tmux detach </span><span style="color:rgb(0, 0, 0)">-</span><span style="color:rgb(0, 0, 0)">s my_session</span></code> </pre> <p><span style="background-color:rgb(255, 255, 255); color:rgb(34, 34, 34)">2. Make the file executable by running:</span></p> <p><code>chmod 755 my_script.sh</code><span style="background-color:rgb(255, 255, 255); color:rgb(34, 34, 34)"> or </span><code>chmod +x my_script.sh</code></p> <p><span style="background-color:rgb(247, 247, 249)">3. T</span><span style="background-color:rgb(255, 255, 255); color:rgb(34, 34, 34)">hen run the shell script:</span></p> <p><span style="background-color:rgb(247, 247, 249); color:rgb(221, 17, 68)">./my_script.sh</span></p> <p><span style="background-color:rgb(255, 255, 255); color:rgb(34, 34, 34)">This tip was originally posted as one of my <a href="http://stackoverflow.com/a/31903189/981183">StackOverflow answers.</a></span></p>
comments powered by Disqus