Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Executing statements inside forloop parallely Post 303016564 by Kamesh G on Sunday 29th of April 2018 09:41:54 AM
Old 04-29-2018
Linux Executing statements inside forloop parallely

Hi All,

I have made a forloop as given below.

Code:
if [[ -f "serv_AAA_DS.ldif" && -s "serv_AAA_DS.ldif" ]]; then 
    echo -e "serv_AAA_DS.ldif file created and will be splitted into 8 smaller files for ldapadd \n"
    sh ./file_splitter.sh
    for (( w=1; w <= 8; ++w ))
    do 
    	nohup ldapadd -x -c -h PL0 -p 389 -D "$LDAP_USER" -w $LDAP_PWD -f serv_AAA_DS.ldif_$w > serv_AAA_DS.ldif_$w.log
    done 
    wait
    serv_AAA_DS_count=`cat serv_AAA_DS.ldif | grep '^dn: ' | wc -l`
    echo -e "Count of serv AAA entries present in the Input file is $serv_AAA_DS_count, cross-check the value with total_dm.sh counters & also the check the failures if any in serv_AAA_DS.ldif_*.log \n"
else 
    echo -e "serv_AAA_DS.ldif is empty and will be removed \n"
    rm serv_AAA_DS.ldif
fi

This one runs sequentially waiting for each iteration to finish inside the forloop, I want to execute all the 8 ldapadd parallel and then the code should wait for all the 8 threads to complete, before it moves to the next lines.

Can you let me know what changes to be done on this to achieve the above mentioned.

Thank you in advance.
Moderator's Comments:
Mod Comment Please use code tags, not bolded text.

Last edited by jim mcnamara; 04-29-2018 at 11:03 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Executing statements after quit in FTP.

In my shell script I am doing FTP along with other process. But all the statements after the "quit" command in FTP are not getting executed. Example: echo "This is a shell script to FTP a file" #ftp -inv <server name> <<eol>> <logfilename> #user <userid> <password> #put <filename> #quit... (2 Replies)
Discussion started by: dharmesht
2 Replies

2. Shell Programming and Scripting

Problem in executing a comand liying inside a variable

Hi everyone! I need some help with my shell script :( I am sending a shell command from a html text input to a cgi. Then, I store it into a variable. For example var="ps -axu" echo `$var` This functions properly. But consider the following... var="ps -axu | grep root" Now, I want... (2 Replies)
Discussion started by: Nene
2 Replies

3. Shell Programming and Scripting

executing 2 or more files inside another file parallely

hi All, i have 3 files file1 file2 file3 these 3 files are shell (KSH) scripts. i want to place all these 3 shell scripts in another file file99 and execute these files simultaneoulsy inside the file99 these 3 files should be present and executed simultaneously when i excute file99 (nohup... (1 Reply)
Discussion started by: dareman123
1 Replies

4. UNIX for Dummies Questions & Answers

Problem with executing command inside a cron job

Hi All, I have scheduled a script in cron which writes output to the below file. ....>> /data/Target/wrapper_invoke_ds_job_`date '+%Y%m%d'`.ksh_out 2>&1 But the date command is not getting resolved in the format specified. It just resolves to the following. wrapper_invoke_MQ_ds_job_Tue... (3 Replies)
Discussion started by: pkm_oec
3 Replies

5. Shell Programming and Scripting

compare parallely

hi, i have folder backup and it contains 3 sub-directories , i want to compare /backup/1 with /recover/1 and /backup/2 with /recover/2 etc . parallelly with using shell scripting . pls help me thanks (2 Replies)
Discussion started by: shankr3
2 Replies

6. Programming

Executing a awk command inside perl script --

Hello experts I want to execute a awk command, which reads from txt files and sums the numbers from the first column for those listed only inside a <init> block -- The awk command is like awk '/<\/?init>/{x = !x}x{a++}x && a > 2{sum+=$1}END{printf"%E" "\n", sum} So, I want to execute... (2 Replies)
Discussion started by: Alkass
2 Replies

7. Shell Programming and Scripting

Executing multiple ssh commands inside a shell simultaneously

I would like to execute a commands in four different servers through ssh at a single instance(simultaneously). Below are the details with examples, ssh user1@server1 "grep xxxx logs" ssh user1@server2 "grep xxxx logs" ssh user1@server3 "grep xxxx logs" Each statement will take some... (4 Replies)
Discussion started by: Amutha
4 Replies

8. Shell Programming and Scripting

How to run scripts parallely inside shell script?

Hi , I have 4 scripts example script1,script2,script3,script4 . I have to run script1,script2 and script3 parallely since this 3 scripts dont have dependencies . Once script1,script2 and script3 got completed successfully , I have to trigger script4. Can someone help me on this how to... (10 Replies)
Discussion started by: vinothsekark
10 Replies

9. Shell Programming and Scripting

Double forloop?

how do I do a double forloop or any other loops like this reads txt file a read first line read txt file b read first line then run command lun map $line1_from_txtA $line1_from_txtB exit (14 Replies)
Discussion started by: tdubb123
14 Replies

10. Shell Programming and Scripting

Executing sed command inside a bash script

I want to run commands inside a bash script. An example is I want to pass the command in a string as regexp as an argument to the script, then run sed on the bash variable sed.sh regexp sed.sh "-i \"s/<p>//g\"" then call sed "$regexp" $fl (3 Replies)
Discussion started by: Kangol
3 Replies
SLAPCAT(8C)															       SLAPCAT(8C)

NAME
slapcat - SLAPD database to LDIF utility SYNOPSIS
/usr/sbin/slapcat [-v] [-c] [-d level] [-b suffix] [-n dbnum] [-f slapd.conf] [-l ldif-file] DESCRIPTION
Slapcat is used to generate an LDAP Directory Interchange Format (LDIF) output based upon the contents of a slapd(8) database. It opens the given database determined by the database number or suffix and writes the corresponding LDIF to standard output or the specified file. The LDIF generated by this tool is suitable for use with slapadd(8). As the entries are in database order, not superior first order, they cannot be loaded with ldapadd(8) without being reordered. OPTIONS
-v enable verbose mode. -c enable continue (ignore errors) mode. -d level enable debugging messages as defined by the specified level. -b suffix Use the specified suffix to determine which database to generate output for. The -b cannot be used in conjunction with the -n option. -n dbnum Generate output for the dbnum-th database listed in the configuration file. The -n cannot be used in conjunction with the -b option. -f slapd.conf specify an alternative slapd.conf(5) file. -l ldif-file Write LDIF to specified file instead of standard output. Limitations Your slapd(8) should not be running (at least, not in read-write mode) when you do this to ensure consistency of the database. EXAMPLES
To make a text backup of your SLAPD database and put it in a file called ldif, give the command: /usr/sbin/slapcat -l ldif SEE ALSO
ldap(3), ldif(5), slapadd(8), ldapadd(1), slapd(8) "OpenLDAP Administrator's Guide" (http://www.OpenLDAP.org/doc/admin/) ACKNOWLEDGEMENTS
OpenLDAP is developed and maintained by The OpenLDAP Project (http://www.openldap.org/). OpenLDAP is derived from University of Michigan LDAP 3.3 Release. OpenLDAP 2.0.27-Release 2 October 2000 SLAPCAT(8C)
All times are GMT -4. The time now is 05:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy