How to write a shell script that starts tmux session, and then runs a ruby script

后端 未结 6 659
暗喜
暗喜 2020-12-08 03:53

I want to write a shell script that does this:

  • First, create a tmux session
  • Second, run a ruby script called \"run.rb\" INSIDE the tmux session
  • <
6条回答
  •  时光说笑
    2020-12-08 04:38

    #!/bin/bash
    tmux new-session -d -s my_session 'ruby run.rb'
    
    1. Create a file named my_script.sh and give it the above contents.

    2. Make the file executable by running:

      chmod 755 my_script.sh or chmod +x my_script.sh

    3. Then run the shell script:

      ./my_script.sh

    Making the shell script executable

    When you perform the chmod 755 filename command you allow everyone to read and execute the file, and the file owner is allowed to write to the file as well. You may need this for Perl and other scripts that should be run via a webserver. If you apply 755 to a directory, it means that everyone can go to it and get its file listing.

    These permissions are usually translated into textual representation of rwxr-xr-x.

    You can alternatively use chmod +x file_name on a file to make it executable.

提交回复
热议问题