LinuxQuestions.org
Register a domain and help support LQ
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-23-2010, 02:42 AM   #1
DoME69
Member
 
Registered: Jan 2008
Posts: 164

Rep: Reputation: 15
how to ran new process after Sungrid process finished?


Hi...

I want ro ran new command only after sungrid finish his task.

Exp:

qsub -q bla command1 ; command2

command2 start only when job of command1 finished.
 
Old 03-23-2010, 03:17 AM   #2
ArfaSmif
Member
 
Registered: Oct 2008
Location: Brisbane Australia
Distribution: Always back to Fedora
Posts: 263

Rep: Reputation: 52
In bash you have :-

control operator
A token that performs a control function. It is one of the fol-
lowing symbols:
|| & && ; ;; ( ) | |& <newline>

use something like

qsub -q bla command1 && command2

This will run command2 only if the previous command returned successfully.
 
Old 03-23-2010, 03:35 AM   #3
DoME69
Member
 
Registered: Jan 2008
Posts: 164

Original Poster
Rep: Reputation: 15
Hi ArfaSmif

i don't care of successful of the previous command.
i want the second command will start only if the first job command finished.

It's diffrent because at the beginning the first command return successful.

Thanks.
 
Old 03-23-2010, 03:39 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by DoME69 View Post
if the first job command finished.

It's diffrent because at the beginning the first command return successful.

Thanks.
What do you mean by "the first job command finished"? How do you know it is finished? Which commands do you use to find out?

Once we know which commands can be used to determine whether "the first job command finished", we can advise on how to script them.
 
Old 03-23-2010, 03:48 AM   #5
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
I think you need to write a little daemon script that periodically checks if the jobs is still running. This could achieved by either running qstat in your script, or by perhaps looking for a file that your job will write when it finishes.

Here is an example of what I mean:
Code:
#!/bin/bash
JOBID=$(qsub -q foo command1)

while [ qstat | grep ^${JOBID} 2>&1 > /dev/null ] ; do
      sleep 60
done
command2
Cheers,

Evo2

Last edited by evo2; 03-23-2010 at 03:53 AM. Reason: Get JOBID from qsub output
 
Old 03-23-2010, 04:29 AM   #6
DoME69
Member
 
Registered: Jan 2008
Posts: 164

Original Poster
Rep: Reputation: 15
is There anyway do this without script?

Something like:
qsub -q "bla ; command2"
qsub -q bla ; "command2"
qsub -q bla ;; command2

Last edited by DoME69; 03-23-2010 at 04:33 AM.
 
Old 03-23-2010, 05:20 AM   #7
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
Quote:
Originally Posted by DoME69 View Post
is There anyway do this without script?
Why not include command2 in the job that you sumit? I'm assuming that "command1" is a script, if so, just add command2 to the end of the script.
eg
Code:
echo command2 >> command1
qsub -q bla command1
EDIT:
If command1 is not a script, just change what you submit. EG.
Code:
cat > commands << EOF
#!/bin/sh
command1
command2
EOF
qsub -q bla commands
Evo2.

Last edited by evo2; 03-23-2010 at 05:23 AM.
 
Old 03-23-2010, 10:37 AM   #8
DoME69
Member
 
Registered: Jan 2008
Posts: 164

Original Poster
Rep: Reputation: 15
This is not good because
both commands start almost at the same time and not after the previous finished.
 
Old 03-23-2010, 08:17 PM   #9
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
Quote:
Originally Posted by DoME69 View Post
This is not good because
both commands start almost at the same time and not after the previous finished.
Are you sure?

In my last post command2 should not start until command1 has finished running. If this is not the case you need to tell me what "command1" actually is.

Evo2.
 
Old 03-24-2010, 12:29 AM   #10
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by evo2 View Post
Are you sure?

In my last post command2 should not start until command1 has finished running. If this is not the case you need to tell me what "command1" actually is.

Evo2.
+1 to that, or at least we need to know how to determine whether command1 is finished, as per post 4. Seems as if command1 is backgrounding itself or returning after initiating something.
 
  


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
how a father process know which child process send the signal SIGCHLD icoming Programming 10 07-20-2010 08:26 AM
Finding the Process ID of a Process While Initiating the Process senthilmuthiah Linux - Newbie 7 04-02-2009 11:37 AM
Bash Scripting - child process affecting parent process mthaddon Linux - General 1 05-02-2004 02:19 PM


All times are GMT -5. The time now is 02:57 PM.

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