LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-17-2010, 02:20 PM   #1
bpeasey
LQ Newbie
 
Registered: Mar 2005
Posts: 8

Rep: Reputation: 0
How to run same script in parallel from on session? e.g. 5x


Hi,

I have a shell script to refresh some databases. Currently I open 5 sessions and to execute the five scripts.

Today, as test, I tried to see if I could run two refreshes simultaneously from one session using the '&':

. /refresh.ksh db1 &
. /refresh.ksh db2

The first one ran and the second one started only after the first one was finished. Could it be that the script refresh.ksh contains many commands and those are not pushed to the background? If so, what's the best approach to getting 5 db's refresh simultanously from on session?

Thanks,
Brian
 
Old 03-17-2010, 02:39 PM   #2
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 164Reputation: 164
You could screen the processes, but in all likelihood you're going to have better results running them serially rather than parallel.

Code:
screen
. /refresh.ksh db1
[ctrl-a]d
(REPEAT as necessary)

It's also entirely possible the database can only be doing the operations performed in that ksh file serially.
 
Old 03-17-2010, 02:41 PM   #3
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 249Reputation: 249Reputation: 249
Put them on the same line.
./refresh.ksh db1 & ./refresh.ksh db2
 
Old 03-17-2010, 02:43 PM   #4
bpeasey
LQ Newbie
 
Registered: Mar 2005
Posts: 8

Original Poster
Rep: Reputation: 0
Hi,

Will investigate the screen command. I didn't make it clear in my original post but the example I posted was targeting two different databases.

Brian

Quote:
Originally Posted by rweaver View Post
You could screen the processes, but in all likelihood you're going to have better results running them serially rather than parallel.

Code:
screen
. /refresh.ksh db1
[ctrl-a]d
(REPEAT as necessary)

It's also entirely possible the database can only be doing the operations performed in that ksh file serially.
 
Old 03-17-2010, 02:53 PM   #5
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
From what I know of screen (which I admit is limited) it is similar to the way DVTM works, in that it breaks up a console/terminal into "sessions" or separate sub-instances.

As mentioned above, maybe the command or operation you are doing will only work serially anyhow, because it will only refresh one DB at a time, so this may be irrelevant; but:

if you're looking for a way similar to `screen` to run multiple processes within one terminal session, look up DVTM (Dynamic virtual terminal manager) -- it acts like a tiling window manager, except it's for inside terminal environments. I've used it both in an "xterm" type of terminal emulator, and also in a VT outside of X, and it does what it claims to do.

Hope this helps, or is at least interesting

Sasha
 
Old 03-17-2010, 07:53 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
Code:
. /refresh.ksh db1 &
. /refresh.ksh db2
should definitely fire off the first one into the background and immediately start the second one. I think you need to check your code and/or how you're checking for parallel running. There's nothing wrong with that code as is...

IMPORTANT: just noticed due to my copy n paste that it looks like you've got a space between the '.' and the '/'; this will cause it to source the code into the current shell, NOT what you want.
Remove the space and try again; also, post inside code tags next time please.
 
Old 03-18-2010, 11:18 AM   #7
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 164Reputation: 164
For what you're wanting to do, backgrounding ~should~ work. Failing that provided that the refresh.ksh can be run simotaniously (eg it doesn't block in some manner) then screening the processes will let you do that. I wrote a fairly good basic tutorial on screen a while ago.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Scripting: audio playback script - how to run two tasks in parallel? klss Linux - Software 5 01-16-2009 03:17 AM
How to run "evolution --force-shutdown" from a script without an x session" biglesias Linux - Software 2 04-14-2008 11:36 AM
Run intractive ssh session in a bash script MasterC Programming 2 10-15-2007 06:08 PM
How to run a program in an ssh session that will run after you close out the session? dr_zayus69 Linux - Networking 5 03-05-2006 08:15 PM
Cannot find or run the base session script buldir Fedora 1 06-04-2004 09:14 PM


All times are GMT -5. The time now is 06:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration