Share your knowledge at the LQ Wiki.
Go Back > Blogs > Skaperen
User Name


Rate this Entry

Background shell sessions

Posted 03-13-2021 at 11:23 PM by Skaperen
Updated 03-15-2021 at 11:59 PM by Skaperen

welcome to Pi day 3-14! edit: Pi day is over.

i now run lots of background shell sessions. this is implement using the screen program. i have a few wrapper scripts to make it easier to use (than the plain screen command) at the command line level.

bgn creates a new background session. argument 1 is the session name. additional arguments are optional and are the first command. you can also set the virtual screen width and height (default 80x25, maximum 1023x1023) at the time the session is created.

bgi provides input to the background session. if the background session is running a program that is reading input, this command provides the input. this command includes support for backslash encoded binary and control characters. you can also provide some control characters in a form like options. for example, -c can be used for Ctrl-C just like \c can. normally a carriage return input is added to each input (making it into a line) but this is disabled when character options are used. there is also an option to disable it.

bgo outputs the current virtual screen image and lots of scrollback lines.

bgl lists the current background sessions (screen sessions).

bgc connects to a background session.

bgr is a shell scripting tool that lets the script know by exit code 0 if any of one or more session names is running.

bgu is a shell scripting tool that lets the script know if it is running under a background session. if one or more names is given it reports if it is under one of the name sessions.

everything is implemented in Python version 3. one of my 18 logged in users has 20 background shell sessions current operating (all but the music session are idle). pulseaudio and my VPN also run in background sessions.
Posted in Uncategorized
Views 258 Comments 0
« Prev     Main     Next »
Total Comments 0




All times are GMT -5. The time now is 02:07 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration