LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-17-2008, 01:34 AM   #1
tuesday
Member
 
Registered: Mar 2008
Location: Malaysia
Distribution: RedHat Enterprise Linux 4
Posts: 42

Rep: Reputation: 15
Running command simultaneously


Hi guys!

Anyone got any idea regarding this topic? I'm trying to build a script that will run two application but the problem is I failed to make it run simultaneously. Thanks in advance
 
Old 04-17-2008, 01:42 AM   #2
Micro420
Senior Member
 
Registered: Aug 2003
Location: Berkeley, CA
Distribution: Mac OS X Leopard 10.6.2, Windows 2003 Server/Vista/7/XP/2000/NT/98, Ubuntux64, CentOS4.8/5.4
Posts: 2,986

Rep: Reputation: 45
Does it have to run EXACTLY simultaneously?
 
Old 04-17-2008, 02:25 AM   #3
tuesday
Member
 
Registered: Mar 2008
Location: Malaysia
Distribution: RedHat Enterprise Linux 4
Posts: 42

Original Poster
Rep: Reputation: 15
Yes, both of them need to be run for 72 hours, so it will take too much time if I want to run them consecutively.
 
Old 04-17-2008, 02:34 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
You can run them in background and wait for completion before proceeding. For example, if you have two processes, process_1 and process_2 you can do something like this
Code:
#!/bin/bash
#
#  launch first process in background
#
/path/to/process_1 &
#
#  retrieve the pid of the last job
#
pid_1=$!
#
#  launch second process in background (optional)
#
/path/to/process_2 &
#
#  retrieve the pid of the last job (optional)
#
pid_2=$!
#
#  wait for the first process to complete
#
wait $pid_1
#
#  wait for the second process to complete (optional), then go on
#
wait $pid_2
You can launch only the first process in background, then let the second one to complete and finally check if the first process has done.
 
Old 04-17-2008, 04:18 AM   #5
tuesday
Member
 
Registered: Mar 2008
Location: Malaysia
Distribution: RedHat Enterprise Linux 4
Posts: 42

Original Poster
Rep: Reputation: 15
Hey thanks. I'll give it a try after this
 
Old 04-17-2008, 04:28 AM   #6
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
If they don't need to be at exactly the same time, try using "at" - two entries both set to start at the same time (or "at now")
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Installing simultaneously to running problem bernbe01 Slackware 5 11-07-2006 01:50 PM
Running wget multiple downloads simultaneously stefaandk Linux - Newbie 1 09-04-2006 07:46 AM
Running 2+ window managers simultaneously? 1 screen, 1 X-server. j4mes Linux - Software 2 02-05-2006 11:30 AM
running 2 USB webcam simultaneously aherrys Linux - Software 4 01-14-2006 03:11 AM
running sata and ide simultaneously ewillens Linux - Newbie 0 08-04-2003 12:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:41 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
Open Source Consulting | Domain Registration