this post was submitted on 03 Feb 2024
22 points (92.3% liked)

Linux

46794 readers
1217 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

I want to launch Oobabooga Textgen WebUI from the command line with its serial output. I also want to run a while loop that retrieves the Nvidia GPU memory available and temperature for display on the header bar with a 5 second sleep delay. How do I run both of those at the same time?

all 19 comments
sorted by: hot top controversial new old
[–] [email protected] 19 points 6 months ago (2 children)

as already mentioned, ampersand allows you to "background" a task. but if you'd like the output from your program alongside the loop monitoring system info, consider using a terminal multiplexer like tmux.

on the terminal, this will let you open a "split screen" pane with another shell. you can use hotkeys to create, destroy, or move between views.

[–] [email protected] 1 points 6 months ago

Or something like tee

[–] [email protected] 10 points 6 months ago (2 children)
[–] [email protected] 3 points 6 months ago (1 children)

Indeed that works in the terminal to launch both my function and the application.

How would I do this inside a single function, like launch, then drop into the loop?

[–] [email protected] 13 points 6 months ago (1 children)

I'm having trouble understanding the question.

while true; do update-header-bar-or-whatever; sleep 5; done &
oogabooga

... will run the header update every 5 seconds, while oogabooga is running. Is that what you want?

[–] [email protected] 2 points 6 months ago (2 children)

If I launch like that it would stop at the oobabooga app launch until the job completed then it would resume the loop.

Ultimately, I'm doing more complex stuff and simplifying the question so it may seem slightly overkill to say I need it to work like this. I want to do some container checks, setup, and launch multiple applications with my own parsing flags and some conditional sourcing.

This only part I can't seem to grasp very well is how to run that little loop and update the header while other stuff launches with its serial terminal set to the same one the loop is running inside.

[–] [email protected] 12 points 6 months ago* (last edited 6 months ago)
$ while true; do echo Hello, I updated the header; sleep 5; done &
[1] 1631507
$ Hello, I updated the header
sleep 30; echo Sleep is done.
Hello, I updated the header
Hello, I updated the header
Hello, I updated the header
Hello, I updated the header
Hello, I updated the header
Hello, I updated the header
Hello, I updated the header
Sleep is done.
Hello, I updated the header
$ kill %1
[1]+  Terminated              while true; do
    echo Hello, I updated the header; sleep 5;
done
$

Edit: I'm fairly confident now that you're just thinking the loop will stop when you run oogabooga, but that's not how it works. That up above is how it works; the loop keeps going during the sleep with them both going on the same terminal, then after the sleep process terminates, I kill the loop, but for the whole 30 seconds previous, they were both going. It'll be the same with oogabooga. This the situation you're asking about, yes?

[–] [email protected] 1 points 6 months ago

If you're doing more complex stuff, maybe spend a few days learning the basics of bash

[–] [email protected] 9 points 6 months ago

I would just background the while loop, and then launch your ootaboogah.

[–] [email protected] 5 points 6 months ago

Xterm supports multiple tabs right? Do that? If not then tmux.

[–] [email protected] 3 points 6 months ago

I'd just use tmux. Check NetworkChuck's recent video on the topic

[–] [email protected] 2 points 6 months ago

You probably want to make a launcher script. An easy start would be to background your main process and route the output wherever you want. Run your monitor loop and send the output wherever you want. Then you can examine and kill the main background pid on script exit. The simplest way in bash might be something like kill $(jobs -p)

This can get a bit more complicated if you want it all to exit if anything fails or something like that. Read up on pkill, disown, kill, $$, trap…tons of possibilities

Some of these things aren’t very portable though, so do check if you decide to switch shells….or do what the rest of us do and scratch your head for an hour before cussing ourselves for not being posix compliant, swear we will next time, then don’t

[–] [email protected] 2 points 6 months ago

Is there a particular reason you can't just open 2 xterm and run each command in its own ?

[–] [email protected] 2 points 6 months ago (1 children)

Shouldn't your LLM be solving this problem.for you? 😂

Seriously though, if not two terms, then just background one or both of these commands.

[–] [email protected] 1 points 6 months ago

I didn't ask AI about this one yet. It could likely give me most of the answers here to various degrees. My best models are similar in scope to stack exchange combined with the randomness of whatever happens to pop up first in DDG results. It isn't good at explaining the various ways a task can be done in practice. Like it likely 'knows' all the various ways, and will generate each of them if prompted slightly differently from scratch each time. But, if you try and have a longer dialog context where it has previously generated a solution, it will likely struggle to accurately describe other methods. LLMs are also pretty good with bash, but they suck at sh or busybox's ash. There is just not enough training data present in these niches with the general models.

However, I asked here primarily in an attempt to increase my posts contributions to Lemmy in hopes of keeping people engaged and around long term. Who doesn't like helping random people with things in this format. I could easily find the answer to this on my own. Asking something on the back of my mind that I have been putting off was just engagement and trying to improve my fundamental scripting skills. Sorry if that somehow offends.

[–] [email protected] 1 points 6 months ago

Gnu parallels perhaps

[–] [email protected] 1 points 6 months ago

Amp-off and use nohup