rodrigosantosbr

[Fedora Remix] Background Task Support in WSL

Feb 17th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!

[Fedora Remix] Background Task Support in WSL

Introduction

Starting in Windows Insiders Build 17046, WSL supports background tasks (including daemons).
In the past, if you opened WSL and started sshd, httpd, screen, or tmux you needed to have a console window open to keep those tools running.
But, starting with 17046, these processes will continue running in the background even after the last console window has been closed.

STEP 1: install tmux

sudo dnf install tmux

STEP 2: creating a new tmux session and naming it

tmux new -s backgroundsession

STEP 3: running background task using nohup

I am going to run mongod and mongoui in this background task.

nohup /usr/bin/mongod &
nohup mongoui &

STEP 4: closing WSL window

Now that I have a task running in WSL, I can close the window without the session terminating.
Go ahead and close the window and open up a new one.

STEP 5: Check if tmux sessions are running.

tmux ls

You can see the tmux session with mongod and mongoui has been and is still running in the background.

STEP 6: To access backgroundsession:

tmux attach -t backgroundsession
Add Comment
Please, Sign In to add comment