Continously updating

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange I'm trying to have a script continuously run a loop that updates a variable in the background, so that the variable is up to date each time it is used.

you can either - as has been suggested, get bash to send its output somewhere else, and then read the data from a separate process or you could put this modified version of your code in a file: session_for i in seq 1 2 3 4 5 do SECONDSINSESSION=$SECONDS SECONDSINMINUTE=60 SECONDSINHOUR=3600 SECONDSINDAY=86400 DAYSINSESSION=$(expr "$SECONDSINSESSION" / "$SECONDSINDAY") DAY_REMAINDER=$(expr "$SECONDSINSESSION" % "$SECONDSINDAY") HOURSINSESSION=$(expr "$DAY_REMAINDER" / "$SECONDSINHOUR") HOUR_REMAINDER=$(expr "$DAY_REMAINDER" % "$SECONDSINHOUR") MINUTESINSESSION=$(expr "$HOUR_REMAINDER" / "$SECONDSINMINUTE") SECONDSINSESSION=$(expr "$HOUR_REMAINDER" % "$SECONDSINMINUTE") SESSIONLENGTH="$DAYSINSESSION days, $HOURSINSESSION hours, $MINUTESINSESSION minutes, and $SECONDSINSESSION seconds." echo $SESSIONLENGTH sleep 2 done $ source session_0 days, 0 hours, 46 minutes, and 26 seconds.

It looks like PRTG Network Monitor can only produce static graphs and then refresh them at an interval (limited to 5 seconds).

If I then toggle GUI B to plot, the display in GUI A holds at the last frame and GUI B starts to display continuous random data.

When I un-toggle the GUI B plot button, GUI A resumes continuous plotting.

SECONDSINSESSION=$SECONDS SECONDSINMINUTE=60 SECONDSINHOUR=3600 SECONDSINDAY=86400 DAYSINSESSION=$(expr "$SECONDSINSESSION" / "$SECONDSINDAY") DAY_REMAINDER=$(expr "$SECONDSINSESSION" % "$SECONDSINDAY") HOURSINSESSION=$(expr "$DAY_REMAINDER" / "$SECONDSINHOUR") HOUR_REMAINDER=$(expr "$DAY_REMAINDER" % "$SECONDSINHOUR") MINUTESINSESSION=$(expr "$HOUR_REMAINDER" / "$SECONDSINMINUTE") SECONDSINSESSION=$(expr "$HOUR_REMAINDER" % "$SECONDSINMINUTE") SESSIONLENGTH="$DAYSINSESSION days, $HOURSINSESSION hours, $MINUTESINSESSION minutes, and $SECONDSINSESSION seconds." There are a few technical things wrong with your script/approach, but forgetting the technical details for a moment, at an intuitive level what you are trying to do is set some counting process in motion, then at some point in the future - you want to What you are trying to do is solved by concurrency and is the type of thing you do in asynchronous (nodejs, nginx) platforms or single threaded processes running an event loop like vim, or javascript in a web browser. If you create a file when your script is started, then you have the start time.

From the wikipedia concurrency article So what can you do in bash?

Search for continously updating:

continously updating-36

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “continously updating”