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

In summary, the conversation is discussing the possibility of adding new jobs to a list of calculations while the current ones are still running on a Linux work computer. The suggested solutions include using a job scheduler or using a "wait" command to add the new jobs after the current ones finish. The conversation also mentions the option of using a "while" loop to continuously check for the completion of the first job before running the second one.
  • #1
brydustin
205
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
  • #2
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
 
  • #3
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.
 
  • #4
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.
 
  • #5
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) &
 

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

1. What is Linux background calculation?

Linux background calculation refers to the process of running calculations or computations in the background while the user can continue to use their computer for other tasks. This allows for efficient use of resources and does not disrupt the user's workflow.

2. How does Linux handle background calculations?

Linux uses a process scheduling algorithm called Completely Fair Scheduler (CFS) to handle background calculations. This algorithm assigns a priority value to each process and allocates CPU resources accordingly, ensuring that background calculations do not hog all the resources and affect the performance of other tasks.

3. What types of calculations can be run in the background using Linux?

Linux can handle a wide range of calculations, including mathematical calculations, data processing, scientific simulations, and more. It can also run multiple calculations simultaneously, making it a versatile and efficient tool for scientific and research purposes.

4. How can I check the progress of a background calculation in Linux?

To check the progress of a background calculation in Linux, you can use the 'top' command in the terminal. This command displays a list of all running processes, their resource usage, and the progress of background calculations. You can also use the 'ps' command to view the status of a specific process.

5. Can I configure the priority of background calculations in Linux?

Yes, Linux allows users to set the priority of background calculations using the 'nice' command. This command allows you to adjust the priority level of a process, with lower values indicating higher priority. This can be useful when you want to allocate more resources to a specific calculation or task.

Similar threads

Back
Top