Screen – Let commands run in background

后台运行程序Screen:常用命令指南                              


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:

  1. Install it in VPS

yum -y install screen #centos

apt -y install screen #ubuntu

  1. Create a Screen (a background environment)

screen -S NAME_YOU_WANT

  1. 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

  1. Then you can ctrl+a d to exit this Screen or ctrl+a c to enter a new screen. (The commands in Screen are still running)

  2. If you want back to screen:

screen -D -r NAME_YOU_WANT

  1. Other commands:

screen -ls #list all running Screens

screen -wipe #wipe the unavailable Screens

screen -S NAME_YOU_WANT -X quit #kill this Screen

0 0 vote
Article Rating