How to run multiple functions in Background in UNIX Shell Scripting?
Hi,
I am using ksh , i have requirement to run 4 functions in background , 4 functions call are available in a case that case is also in function, i need to execute 1st function it should run in background and return to case and next i will call 2nd function it should run in background and return to case again to ask for anyother option to execute in backgorund.
I tried to
using this 1 functions is being called and running and i am able to call other function but it is displaying as process already exists and the main script itself is getting terminated.
I searched the forum and saw fork(); command but i am not clear to use that and i saw in one forum that it is bad to use that and not advisable.
Please Advise how to achive the functions to run in background and i cant split the script making 4 different scripts.
How to run multiple functions in Background in UNIX Shell Scripting?
Hi DGPickett/Unix tech experts,
Thanks for the idea given, the export is used for the child process to use the variable that i am able to understand, one small query i can use sleep instead of wait but whether the delay is necessary to use ? i need to the function to run in background and return to case for other options. I am currently testing the script will get back if there is any issue.
Delay is not the point, you start all independent tasks and then dependent tasks for each are arranged to wait for all their precedents. Now, only one process can wait for each running process, so if many processed need to know what is done, a log file, directory of marker files or other database can track progress, and you can check progress in a loop every N seconds. You could write a supervisor that knows the prereqs of every new process. You could put the prereqs in a SQL db, same db as the completions, so you can query what is not run and no prereq is missing, and launch any found. You would be writing ControlM or Tivoli TWS and such.
Thanks , as per your advise , i didnt use any delay instead made a condition to check whether the function pid is available which will be executed in a function which called from case (for requirment 4 is the exit made condition to check then exit).
pgrep functionality what you have posted is available in my ksh terminal, but i am not confident about my script and its performance consistency so used the old legacy command, anyway if i get a chance will try like this (pgrep) newer commands , i hope which will be consume lesser memory.
Hello All,
just wanted to export multiple tables from oracle sql using unix shell script to csv file and the below code is exporting only the first table.
Can you please suggest why? or any better idea?
export FILE="/abc/autom/file/geo_JOB.csv"
Export= `sqlplus -s dev01/password@dEV3... (16 Replies)
Hello,
I have a requirement to apply hashing algorithm on flat file on one or more columns dynamically based on header
sample input file
ID|NAME|AGE|GENDER
10|ABC|30|M
20|DEF|20|F
say if i want multiple columns based on the header example id,name or id,age or name,gender and hash and... (13 Replies)
Hi Guys,
i am having a script which checks for ip address is pingable or not,when i execute this script in terminal it keeps on showing the pinging status of every ip address and it takes more time when i check for 100 ip address,How to do run a script in background without showing in the terminal... (4 Replies)
I have written the below query to genrate a telephone.I am passing account number from oracle database.
I am calling 2 scripts which generate the bill
1. bip.sh (it runs in the background)
2.runXitInvoice_PROFORMA_integ
bip.sh generates a number which runXitInvoice_PROFORMA_integ
uses.How... (7 Replies)
Dear All,
I am trying to run a script in background like ./scriptname.sh & but when i try to run it in background it is giving me an error "syntax error at line 12: `(' unexpected" at the line 12, there is a function definition
"function getFileList()".
This script runs fine if i run on... (2 Replies)
hello there,
there's a function, in my shell script, i'd like to run in the background.
here's an example:
log()
{
local SELF=${0##*/}
tty -s && echo ": $*"
}
some_func()
{
# do something
log "This text is not displayed in the terminal's output when running in the... (1 Reply)
I am trying to write a script that will ssh into a remote machine and recurse through a specified directory, find mp3 files which may be two or three directories deep (think iTunes: music/artist/album/song.mp3), and scp them back to the machine running the script. The script should also maintain... (3 Replies)
I have a following program:
echofunc()
{
filename=$1
echo "reading $filename"
while read line
do
echo $line;
sleep 6;
done < $filename
}
split -5 new.dat
ls x* > input.dat
while read file
do
echofun $file &
done < input.dat (3 Replies)