Is there a way to count how many processes a script has started, count how many of these have finished, and make the script wait if their difference goes over a given threshold?
I am using a script to repeatedly execute a code (~100x) which converts 2 data files into one .plt which is in the format for Tecplot. These files are large, 300-1000MB.
The code reads an input file which is altered before each instance of the code is executed. I've done this by hand (never again), and could get about 5-6 instances going at a time (ie the 1st process would finish before I could start the 7th). (The input is read at the very beginning so I can alter it while code is running.)
My problem is once I scripted this process, MANY instances can get going at once, and the computer gets bogged down. I inserted a 'sleep' command, but this isn't robust enough, and depending on other loads on the computer the same problem can happen.
if your script is sufficiently self-aware...in a different shell than the one you've shown...you can go ahead and supply a self-referencing function to grep the ps for itself, to get a count and/or check for file opens (fuser) on the dependent files.
This was actually raised just recently too...as was the deprecated status of the C shell.
yes yes, I've heard all the bashing of csh (no pun intended), unfortunately I've been encouraged by my advisor (i'm a in a phd program) to use tcsh. I've only started using scripts over the past week, and instantly see their value. However, I've very new to unix and am not familiar enough with functions/terminology for the arguments against csh to be very convincing to me.
As for the wait command. I believe I could figure out how to start a few instances, but would have to wait for all of these to complete, before starting another batch. I'd like to get 5 going, then start the sixth as soon as the first finishes, etc. Am I misinterpreting the functionality of 'wait'?
As for grepping 'ps' this was something I had thought about, or even checking out 'uptime' (i'm working with multiple cores, and the code is parallel). I'm pretty sure I could somehow use grepped data to control a loop, which would be like a dynamic sleep command, but was looking for something more direct, this seems like a work-around.
Any other suggestions/advice?
curleb, you mentioned this was brought up recently. Could you direct me to the thread?
Hello everybody ,
I launched cron to execute a task every hour but the job takes more than hour that's why I'm getting more than 1000 cron processes running at the same time !!!
My question is how to tell cron not to execute unless the job terminated in order to have only one process running .... (14 Replies)
Is there a certain man command I'm missing here? I searched in ps but I couldn't find something that would give me the number of processes running on root.
I only want to see the number of processes, not the processes itself. (2 Replies)
Hi can anybody help me regarding this..
i want know the output of ps -ef with explanation.
how can we know the running processess.
this is the output of ps -elf
F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
19 T root 0 0 0 0 SY ... (1 Reply)
Ok, so I know there's a way to do this, but I've been trying to find out all afternoon with no luck. I think it should print out something like this:
1 bin
2 daemon
6 duo
Where the numbers on the left are the number of processes being run by the user whose name is listed on the right. Is... (4 Replies)
I have a script something like this:
#!/usr/bin/ksh
CLASSPATH=/apps/opt/db2udb/admin/db2bdt/sqllib/java/db2java.zip:/apps/opt/db2udb/admin/db2bdt/sqllib/java/db2jcc.jar:/apps/opt/db2udb/admin/db2bdt/sqllib/function:$CLASSPATH
export CLASSPATH
... (7 Replies)
I'm doing a script with the Shell. I need that it only show the number of running processes.
Ex:
echo "There are `command` running processes"
Thnx!
Pd: Sorry the idiom. I'm spanish. (2 Replies)
I've got a bit of code I'm trying to work on...
What i want to happen is ... at all times have four parallel mysql dump and imports running.
I found the follow code snippet on the forum and modified it to work
by starting four concurrent processes but it waits until all four are done before... (7 Replies)
I am pretty new to unix, and I have a project to do.
Part of the project asks me to determine the number of processes running and assign it to a variable. I know how to every part of the project but determine the number of processes running.
How can I get just the number of processes... (4 Replies)