When we have to run some commands for a long time like install large environments or download some media, the offline to the network will stop your commands and hard to recover them. It is terrible and cloud waste much time.
Now the Screen is a good tool to keep the commands running in the background.
Even the commands will keep accessing after you close the ssh connection.
So, how to use Screen tool:
- Install it in VPS
yum -y install screen #centos
apt -y install screen #ubuntu
- Create a Screen (a background environment)
screen -S NAME_YOU_WANT
- Now your terminal has entered the Screen named NAME_YOU_WANT, you can run the commands which need lots of time in the backgroud, like download m3u8 video stream:
ffmpeg -i index.m3u8 -acodec copy -vcodec copy output.mp4
Then you can
dto exit this Screen or
cto enter a new screen. (The commands in Screen are still running)
If you want back to screen:
screen -D -r NAME_YOU_WANT
- Other commands:
screen -ls #list all running Screens
screen -wipe #wipe the unavailable Screens
screen -S NAME_YOU_WANT -X quit #kill this Screen