Run Any Command in Background [Linux/Unix]

Some command takes time to execute or we need to run the command continuously so we need to take it on the background.

Arnish Gupta
1 min readDec 1, 2020
Photo by Aron Visuals on Unsplash

There are many packages available to execute the command in the background but the most popular and easy approach is for Screen Command. Let’s understand how it works.

Installation

Firstly we have to install the screen package on our machine. In some operating system screen package already installed.

[CENTOS] yum install screen -y

[LINUX] apt-get install screen -y

Used

### We have to open the new screen using the below commandscreen -s <Tag_Name> (Here Tag_Name is for identity it is optional)Example: 
screen -s mysite (With Tag)
screen (without the tag)
## You can do whatever you want and come to the original screen
CTRL + a (then press 'd') ## It detached the screen## For list of running screensscreen -ls## For go to the specific screenscreen -r <Screen_ID> (You can find Screen_ID on screen -ls command)## For Kill/Exit the screenCTRL + a (then press 'k') then press 'y' (it ask for confirmation)

Thank you for reading !! Have a Good Day (sudo :))

--

--

Arnish Gupta

Learn Blockchain with me every Monday at 9AM (GMT+5:30).