linux run in background code example
Example 1: run screen on background linux terminal
# Install screen
yum install screen
# Initiate a Screen
screen -S <screen name> <command to execute>
# Detach from the screen
CTRL + A, D
# List all the screen currently working
screen -ls
# Reattach to a screen
screen -r <screen name>
# Kill specific screen
screen -X -S <screen name> quit
# Kill all screens
pkill screen
Example 2: linux run background
nohup ./myscript.sh & # runs in background
nohup ./myscript.sh # output is in nohup.out
nohup ./myscript.sh > myscript.log & # output is in myscript.log
Example 3: linux run task in background
[command] 2> /dev/null &