Calling multiple functions in parallel


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Calling multiple functions in parallel
# 1  
Old 06-20-2012
Calling multiple functions in parallel

Hello,

I have multiple functions within a shell script. eg. function_database_backup, unix_tar_creation, etc.

I would like to run these functions in parallel, as each is independent of the other.

If these were simple commands, I could have probably run each of the commands in background.

My question is, how can I call multiple functions to execute in parallel in ksh?

Appreciate your help.
# 2  
Old 06-20-2012
Can you have those two functions in two separate file? If so, then you can run first load them and run them at your prompt as commands.

Code:
[user@host ~]# cat add2_3.fn
add2_3 () {
    x=$((2 + 3))
    echo x
    sleep 4
    echo "coming out of add fn"
}
[user@host ~]#
[user@host ~]# cat mul2_3.fn
mul2_3 () {
    x=$((2 * 3))
    echo $x
    sleep 5
    echo "coming out of multiply fn"
}
[user@host ~]#
[user@host ~]# . ./add2_3.fn
[user@host ~]# . ./mul2_3.fn
[user@host ~]#
[user@host ~]# add2_3 &
[user@host ~]# mul2_3 &

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash calling a few functions syntax error

In the bash function below if the user selets "y" then the menu function is called and if they select "n" the move function is called. That all seems to work, my question is after the files are moved an echo, line in bold is displayed and another function called backup is called. I am getting a... (1 Reply)
Discussion started by: cmccabe
1 Replies

2. Shell Programming and Scripting

Calling Bash Functions in the BG

I'm trying to call some functions in the background so that I can multitask in this script. Not working so hot. The functions I call don't ever seem to get called. I'm doing it the exact same way in another script and it's working like a champ so I'm very confused. Here's a pretty simple repro: ... (7 Replies)
Discussion started by: stonkers
7 Replies

3. Shell Programming and Scripting

Parallel processing for functions in xargs

I have a script (ksh) which tries to run a function in parallel for performance gains. I am also trying to limit the number of parallel child processes to avoid overloading the system by using a variable to count triggered processes and waiting for completion e.g. do_something () { ... } ... (9 Replies)
Discussion started by: jawsnnn
9 Replies

4. Shell Programming and Scripting

Calling same procedure in parallel

hi , I want to call same oracle procedure with different arguments in parallel. how can i do this in shell script. Pls help. (4 Replies)
Discussion started by: Pratiksha Mehra
4 Replies

5. Shell Programming and Scripting

Pass parameters to a function and running functions in parallel

Hi , I have a script which is using a text file as I/P. I want a code where it reads n lines from this file and pass the parameters to a function and now this script should run in such a way where a function can be called in parallel with different parameters. Please find below my script, it... (1 Reply)
Discussion started by: Ravindra Swan
1 Replies

6. AIX

Calling functions from main program from dlopened library function

Hello All, I am trying to call a function from the calling main program from a dlopened library function, below is the entire code, when I execute it it crashes with sigill. Can you guys help me out I guess I am missing out on the linker flag or something here. besides I am new to AIX and... (1 Reply)
Discussion started by: syedtoah
1 Replies

7. Shell Programming and Scripting

Is it possible make the shell read functions 1 by 1 and calling an other function?

Greetings, I m wondering if it's possible do do the following : I have a simple function called "FindMoveDelete" which does the following : FindMoveDelete() { find . -iname "$FILENAME*.ext" -exec mv {} "$PATH/$VAR" \; && find . -maxdepth 1 -type d -iname "$FILENAME*" -exec rm -rf {}... (6 Replies)
Discussion started by: Sekullos
6 Replies

8. Shell Programming and Scripting

Calling Functions of Other K Shell Program

Hi, I have a K shell a.ksh function abc { // Some logic } In b.ksh i have included the a.ksh ./a.ksh I want to call the abc function from this b.ksh script. Thanks Vijay (2 Replies)
Discussion started by: vijaykrc
2 Replies

9. Shell Programming and Scripting

Multiple functions

Hi, which of the shell support multiple functions in a shell script? Thanks Amit (1 Reply)
Discussion started by: amitrajvarma
1 Replies

10. Shell Programming and Scripting

Calling functions in scripts directly

Hi, I have a menu driven script that does various tasks, I want to be able to call functions directly from within other unix scripts from my menu script. Is this possible? (12 Replies)
Discussion started by: LiquidChild
12 Replies
Login or Register to Ask a Question