How to loop this process?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to loop this process?
# 8  
Old 11-15-2010
I suppose seq loses points for fork/exec! In ksh, you have c-ish math in (()):
Code:
$ i=0;while (( ( i+= 1 ) < 6 ))
do
echo Processing $i
done
Processing 1
Processing 2
Processing 3
Processing 4
Processing 5
$

# 9  
Old 11-15-2010
Quote:
Originally Posted by DGPickett
I suppose seq loses points for fork/exec! In ksh, you have c-ish math in (()):
Code:
$ i=0;while (( ( i+= 1 ) < 6 ))
do
echo Processing $i
done
Processing 1
Processing 2
Processing 3
Processing 4
Processing 5
$

seq is alternative solution in this..like you say builtin (keyword) solutions are better and fast because of the access shell inertals is more easy to consider the fork() process Smilie
# 10  
Old 11-15-2010
Actually, execvp() takes about 10x more time than fork(), never mind vfork(), understandably as it has to search PATH and do loading and dynamic linking. Smilie
# 11  
Old 11-16-2010
Quote:
Originally Posted by DGPickett
Actually, execvp() takes about 10x more time than fork(), never mind vfork(), understandably as it has to search PATH and do loading and dynamic linking. Smilie
Smilie but if we think work in current shell (not in a script) which logged in then i think have no use for load the dynamic links (already loaded with current shell)
# 12  
Old 11-16-2010
Dynamic linking is done afresh with every exec*(). even though the pages are almost certainly in RAM, still, it takes substantially more time. This is good to remember in case you ever get the idea that dividing code into two smaller processes will save time.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Process files in loop which have spaces in name

I have a folder with files and I have to process them in a loop. However the filenames have space characters, so the list get split. $ touch "File Number_1" $ touch "File Number_2" $ ls "/tmp/File Number"_* /tmp/File Number_1 /tmp/File Number_2 I tried following (sorry for using the... (3 Replies)
Discussion started by: Wernfried
3 Replies

2. Shell Programming and Scripting

Script to loop process

As I would like to test the open files usage , I would like to have a process that use the open files up to a certain amount eg. 1000 . If I want to have a script ( may be run in a loop ) that could repeatly use open files resource , so that the usage of open files increases , may I know how to... (10 Replies)
Discussion started by: ust
10 Replies

3. UNIX for Dummies Questions & Answers

For loop in process each file

Hi I have following codecd /tmp/test/ for vfile in `ls -1` do for vlink in `ls -l /tmp/testfile/*|bin/grep "local/init\.d/$vfile$"|bin/awk -F"->" '{print($1)}'|bin/awk -F"/" '{print($NF)}'` I know `ls -1` list only file, but I don't... (3 Replies)
Discussion started by: stew
3 Replies

4. UNIX for Dummies Questions & Answers

Timed loop to scan for a process

Hi all, Looking for some help, I have written a very simple script to pass to PowerHA to act as an indicator to activate failover required. Where i get completely lost is I have to create a wait and carry out the grep for the process once every 10 seconds this works but need to embed this... (1 Reply)
Discussion started by: Gary Hay
1 Replies

5. Shell Programming and Scripting

need to process for loop faster

I have the following code running against a file. The file can have upwards of 10000 lines. problem is, the for loop takes a while to go through all those lines. is there a faster way to go about it? for line in `grep -P "${MONTH} ${DAY}," file | ${AWK} -F" " '{print $4}' | awk -F":"... (2 Replies)
Discussion started by: SkySmart
2 Replies

6. Shell Programming and Scripting

Loop to process 2 files with same name in different path

Hello forum members, I hope you can help me with this I don't know hot to reach. I have a list of files in "/home/MyPath1/" and in "/home/MyPath2/". The files have the same name in both folders. (but different content, the content doesn't matter here I think) /home/MyPath1/ filename1.txt... (4 Replies)
Discussion started by: Ophiuchus
4 Replies

7. Shell Programming and Scripting

Process checking loop

Hi, I want to create a script who will check if the java process is running & if it finds the process is still there it continues to execute & when the process completes it exit from the script. I have written a code to check & notify the process existence but i am not getting how to write... (4 Replies)
Discussion started by: d8011
4 Replies

8. Shell Programming and Scripting

loop when process running

Hi Gurus, Could you please help me to create a shell script that will be started by a cron job once every night at 24.00 h (that should bee easy:)) The shell script should control every 30 seconds the name of a process, and when the process doesn't run anymore it should execute a few further... (12 Replies)
Discussion started by: blackwire
12 Replies

9. Shell Programming and Scripting

Check for statup process in loop?

I've written a script to check for Oracle's listener, eventman and pmon processes however there are several databases that startup which can take several minutes. I'd like to add code to my current script that greps for the process “startup” and whether its condition is true or false. If the... (1 Reply)
Discussion started by: dataciph3r
1 Replies

10. Shell Programming and Scripting

loop of killing and calling process

I make two process killing and calling one process I want to do this repeatedly many time between the interval(sleep) What will be the command to do this, can you make as one do use sleep between and run clear the memory(sh sync.sh) I need your advice, the script will be like this killps... (1 Reply)
Discussion started by: 197oo302
1 Replies
Login or Register to Ask a Question