What is the best way to add new calculations to a running list in Linux?

  • Thread starter Thread starter brydustin
  • Start date Start date
  • Tags Tags
    Calculations Linux
AI Thread Summary
To manage multiple jobs on a Linux system while ensuring that new calculations start only after current ones finish, users can utilize job control commands effectively. It is not possible to insert new jobs into a running shell session directly. Instead, commands like "wait" can be employed to pause the execution of subsequent jobs until the current job completes. Specifically, using "wait %1" allows the new job to wait for the completion of the first job identified by its job number. For more complex scheduling, users can run background jobs and monitor their status using process IDs (PIDs). A common approach involves using a "while" loop to check if the first job is still running, and once it finishes, the next job can be executed. This method allows for efficient load balancing and job scheduling without manual intervention. Additionally, exploring job schedulers designed for high-performance computing can provide more robust solutions for managing multiple tasks.
brydustin
Messages
201
Reaction score
0
hi,
I'm running some calculations in the background of my Linux work computer, and I now have some more jobs for it to do, but the current calculations are not yet finished. For example, my new file, RUN.in has the following:
./cal1
./cal2
./cal3
./etc

and this is similar to what I have running right now in my first list, except that I want to "append the list".
Can I just go into the first List of calculations and literally add these new jobs, whilst the current ones are running (by adding the list of RUN.in to the end of the first list which looks like RUN.in)... or is it possible to run the new list of calculations under the list "RUN.in" but not do it manually after the first is finished (i.e. give the computer instructions to do it next even if I'm not present)
... or is it possible to do either (i.e. append to list OR tell it to do the RUN.in list next)?
Help much appreciate thanx
 
Computer science news on Phys.org
You can't insert the lines AFTER the shell is already running.

What about

user@host:/tmp$ RUN1.in &
[1] 1234
user@host:/tmp$ wait %1 ; RUN2.in &

Or maybe:

user@host:/tmp$ ( RUN1.in ; RUN2.in) &
[1] 2768
 
If you want to do this sort of thing regularly, look at
http://en.wikipedia.org/wiki/Job_scheduler#Batch_queuing_for_HPC_clusters

Not all those apps are free software (and the ones I have used personally are not free) but it I bet somebody in the Linux community has written a freeware solution.

Don't be put off by the "high performance computing clusters" description. They are also useful for load-balancing on a single computer, which is what you are trying to do.
 
Rogerio said:
You can't insert the lines AFTER the shell is already running.

What about

user@host:/tmp$ RUN1.in &
[1] 1234
user@host:/tmp$ wait %1 ; RUN2.in &

Or maybe:

user@host:/tmp$ ( RUN1.in ; RUN2.in) &
[1] 2768

Specifically what will
user@host:/tmp$ wait %1 ; RUN2.in &
do?? I just want to be very careful not to make a mistake (i.e. the calculations are going now, and don't want to waste any time). Does "wait" mean that the new job is "waiting" for the first (current) one to finish? If so... that's exactly what I want.
 
brydustin said:
Specifically what will
user@host:/tmp$ wait %1 ; RUN2.in &
do?? I just want to be very careful not to make a mistake (i.e. the calculations are going now, and don't want to waste any time). Does "wait" mean that the new job is "waiting" for the first (current) one to finish? If so... that's exactly what I want.

Yes, it does. But... the "wait" has to be in foreground (or it won't know who is the "%1" job) at the SAME shell session where the "Job %1" is running.

Being so, maybe you prefer to use:
user@host:/tmp$ RUN1.in &
[1] 1234

And then, at ANY shell session (or any terminal):
user@host:/tmp$ (while kill -0 1234; do sleep 60; done); RUN2.in &

The "while" keeps testing the existence of the process 1234 (the first job PID) every 60 seconds, and, when it is gone, the "RUN2.in" command will be called.
The while will run on foreground, and the RUN2 at background.

If you prefer everything at background:
user@host:/tmp$ ((while kill -0 1234; do sleep 60; done); RUN2.in) &
 
In my discussions elsewhere, I've noticed a lot of disagreement regarding AI. A question that comes up is, "Is AI hype?" Unfortunately, when this question is asked, the one asking, as far as I can tell, may mean one of three things which can lead to lots of confusion. I'll list them out now for clarity. 1. Can AI do everything a human can do and how close are we to that? 2. Are corporations and governments using the promise of AI to gain more power for themselves? 3. Are AI and transhumans...
Thread 'ChatGPT Examples, Good and Bad'
I've been experimenting with ChatGPT. Some results are good, some very very bad. I think examples can help expose the properties of this AI. Maybe you can post some of your favorite examples and tell us what they reveal about the properties of this AI. (I had problems with copy/paste of text and formatting, so I'm posting my examples as screen shots. That is a promising start. :smile: But then I provided values V=1, R1=1, R2=2, R3=3 and asked for the value of I. At first, it said...
Back
Top