You have a couple of choices. The most basic would be to use nohup
:
nohup ./execute.sh
nohup
executes the command as a child process and detaches from terminal and continues running if it receives SIGHUP
. This signal means sig hangup
and will getting triggered if you close a terminal and a process is still attached to it.
The output of the process will getting redirected to a file, per default nohup.out
located in the current directory.
You may also use bash
's disown
functionality. You can start a script in bash:
./execute.sh
Then press Ctrl+z and then enter:
disown
The process will now run in background, detached from the terminal. If you care about the scripts output you may redirect output to a logfile:
./execute.sh > execute.log 2>&1
Another option would be to install screen
on the remote machine, run the command in a screen session and detach from it. You'll find a lot of tutorials about this.