Skip to content

Instantly share code, notes, and snippets.

@leonelsr
Last active March 14, 2024 02:26
Show Gist options
  • Save leonelsr/cde77574519eb1fd672bc9690e01257e to your computer and use it in GitHub Desktop.
Save leonelsr/cde77574519eb1fd672bc9690e01257e to your computer and use it in GitHub Desktop.
Run bash (Windows Subsystem for Linux) in background, in order to keep background processes running in WSL
' Windows Devs said on the developer feedback asking for cron, deamons and background tasks:
' "This first release of Bash/WSL doesn’t support background tasks, cron jobs, daemons, etc.
' Currently, when you close your last bash shell console window, we tear-down the Linux process
' chain in order to conserve resources."
'
' That's the workaround for now.
' You can run it on boot, for example, and it'll keep a instance of bash running alone in the background
' allowing background processes to run on WSL.
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & "bash" & Chr(34), 0
Set WshShell = Nothing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment