How to run multiple instances of shell script in linux? | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

How to run multiple instances of shell script in linux?

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 04-27-2012
anuragpgtgerman anuragpgtgerman is offline
Registered User
 
Join Date: Aug 2011
Last Activity: 23 March 2014, 4:21 PM EDT
Location: India
Posts: 85
Thanks: 0
Thanked 1 Time in 1 Post
How to run multiple instances of shell script in linux?

How we can run the multiple instances of the script? I need to run the script which I am calling from the below function.I can doit with cron but I don't want to put it in the cron.This cript dploy the build and here I want when the build stage then it should run with multilpe instances of colodeolpyall script where it finds the new.txt file ..

Code:
/mnt/projects/stp2perf2_app_runtime/lamb/current.txt
/mnt/projects/stp2perf2_app_runtime/orbitgw/current.txt
/mnt/projects/stp2perf2_app_runtime/stp/wsHUB/current.txt
/mnt/projects/stp2perf2_app_runtime/stp/wsSTP/current.txt
/mnt/projects/stp2perf2_app_runtime/stpbatch/current.txt
/mnt/projects/stp2perf2_app_runtime/stpmon/current.txt
/mnt/projects/stp2perf2_app_runtime/stpscripts/current.txt
/mnt/projects/stp2perf2_app_runtime/stptools/current.txt
/mnt/projects/stp2perf2_app_runtime/tag/current.txt
[stp@VHLDVW stp]$ find /mnt/projects/stp2perf2_web_runtime/* -maxdepth 2 -name current.txt -type f
/mnt/projects/stp2perf2_web_runtime/gdesksrv/current.txt
/mnt/projects/stp2perf2_web_runtime/gdesksrv_lgcy/current.txt
/mnt/projects/stp2perf2_web_runtime/gdesksrv_ungt/current.txt
/mnt/projects/stp2perf2_web_runtime/npg/current.txt
/mnt/projects/stp2perf2_web_runtime/stp/gwSTP/current.txt
/mnt/projects/stp2perf2_web_runtime/stpinbound/current.txt
/mnt/projects/stp2perf2_web_runtime/stpproxy/current.txt
/mnt/projects/stp2perf2_web_runtime/stpscripts/current.txt
/mnt/projects/stp2perf2_web_runtime/stptools/current.txt
/mnt/projects/stp2perf2_web_runtime/stpweb/current.txt


Code:
calldeploy()
   {
   cd /projects/stp/stpbuild/logs/BuildLogs/
   #Type=`grep "Build Type:" < ${LogFile} | awk -F"." '{print $NF}'`
   Type=`cat ${LogFile} | grep -o "Stage" | uniq`
   Pass=`grep "Result:" < ${LogFile} | awk -F"." '{print $NF}'`
   if [[ ${Type} == "Stage" && ${Pass} == "SUCCESSFUL" ]];then
   ssh -l stpuser VHLDVWSAD001 /projects/stp/stputils/deploy/colodeployall.sh &
   fi
   }
   calldeploy

Sponsored Links
    #2  
Old 04-27-2012
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
 
Join Date: Sep 2005
Last Activity: 16 April 2014, 5:27 PM EDT
Location: Switzerland - GE
Posts: 5,490
Thanks: 148
Thanked 361 Times in 338 Posts
Do you mind writing in plain English: I am puzzled with some of your words wondering if I have to understand typo errors or unix commands...
Sponsored Links
    #3  
Old 04-27-2012
anuragpgtgerman anuragpgtgerman is offline
Registered User
 
Join Date: Aug 2011
Last Activity: 23 March 2014, 4:21 PM EDT
Location: India
Posts: 85
Thanks: 0
Thanked 1 Time in 1 Post
I mean I want to run the script multiple times in a single time

my script read the new.txt file and start the deployment i.e do all the joba and restart the servers
But I want if the script has read the new.txt file for one component and restarted the server It should pick the other new.txt for other compoenet and started the server.it should not wait for first that if the server started then will start for other.

Hope this clears
    #4  
Old 04-27-2012
zedex zedex is offline
Registered User
 
Join Date: Feb 2007
Last Activity: 21 July 2013, 6:23 AM EDT
Location: Mumbai, India
Posts: 184
Thanks: 6
Thanked 5 Times in 5 Posts
Well i am not 100% clear about what you want to do, but i think you want to read the "New.txt" file and then start all the jobs inside that file and restart the server (not sure which servers, may be mentioned in file??)

Pseudo code:


Code:
for config_file in `find . -type f -name current.txt`
do 
     <SCRIPT-TO-DO-DESIRED-THINGS> $config_file & 
done

Well not sure if this is what you are looking .. but looks like you want to run same script in parallel with different inputs
Sponsored Links
    #5  
Old 04-27-2012
anuragpgtgerman anuragpgtgerman is offline
Registered User
 
Join Date: Aug 2011
Last Activity: 23 March 2014, 4:21 PM EDT
Location: India
Posts: 85
Thanks: 0
Thanked 1 Time in 1 Post
My script reads the new.txt file and then it check the name in new.txt file and deploy that on the enviorment and restart the nodes(only script does this)

My intention is if new.txt exist on 2-3 enviorments then my script should run in this way .i.e. script will run new.txt read it and start the nodes but it should not wait for the completion of restart all the node but read the next new.txt and restart that nodes...simillary for others

Hopes thi clears
Sponsored Links
    #6  
Old 04-28-2012
pokerino pokerino is offline
Registered User
 
Join Date: Apr 2012
Last Activity: 8 July 2012, 7:16 AM EDT
Posts: 36
Thanks: 0
Thanked 5 Times in 5 Posts
Hi,

try with:
Quote:
cat new.txt |xargs -P <numeber of desired process> command
Sponsored Links
    #7  
Old 04-28-2012
anuragpgtgerman anuragpgtgerman is offline
Registered User
 
Join Date: Aug 2011
Last Activity: 23 March 2014, 4:21 PM EDT
Location: India
Posts: 85
Thanks: 0
Thanked 1 Time in 1 Post
Can someone help to know about the multithreading process?
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Shell script to login into multiple linux boxes Mani2512 Shell Programming and Scripting 2 07-21-2011 12:22 AM
Want to have delay in multiple instances of the same shell script chetan_sonar Shell Programming and Scripting 3 05-25-2010 08:08 AM
Get the STATE of the weblogic instances via shell script. joshilalit2004 Shell Programming and Scripting 2 04-06-2010 07:57 AM
Multiple instances of the job in shell script. Gangegowda Shell Programming and Scripting 1 11-03-2008 05:29 AM
script to create multiple instances of a user account across LPAR's kcampbell Filesystems, Disks and Memory 1 10-19-2006 10:42 PM



All times are GMT -4. The time now is 02:43 AM.