LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-13-2007, 08:11 AM   #1
horacioemilio
Member
 
Registered: Dec 2007
Posts: 61

Rep: Reputation: 15
Send process to a node in background and logout


Hi, I am trying to get a script running out which sends jobs to a list of nodes like the following;

Code:
#!/bin/bash


for i in `seq $1 $2`
do
        # 1. create directory with the right name 
        #    taking into account possible different rounds of jobs
        rm -fr job_node$i
        mkdir job_node$i
        cp -r /some_funny_folder_base_files job_node$i

        # 3. launch the job on this node
        echo " cd /somepath/job_node$i/1st_run; nohup ./run.exe inputfile &"  | ssh node$i     
        
done
but the problem is that is stops on the first node an the output of the program on the screen. If I manually log onto each node and send the calculation using
Code:
nohup ./run.exe inputfile &
then the program starts to run and I can logout withhout problems.

So what should I do to leave the programs running on each node with this script or some other solution ?

thanks
 
Old 12-13-2007, 03:10 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
How about executing the command on multiple servers at the same time using something like ClusterSSH instead?
 
Old 12-14-2007, 04:58 AM   #3
horacioemilio
Member
 
Registered: Dec 2007
Posts: 61

Original Poster
Rep: Reputation: 15
it would be interesting but in this machine i can not install anything

Quote:
Originally Posted by unSpawn View Post
How about executing the command on multiple servers at the same time using something like ClusterSSH instead?
 
Old 12-14-2007, 06:36 AM   #4
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
I think you may need to launch your child process(es) like this
Code:
...
nohup ./run.exe inputfile >> /dev/null 2>>/dev/null &
...
That is, without piping the output of the parent or run.exe into ssh in the parent process -- do the pipe in run.exe instead, passing any necessary arguments to it from the parent
Code:
...
nohup ./run.exe ${ARG1} ${ARG2} inputfile >> /dev/null 2>>/dev/null &
...
You need to handle your output to ssh or any log files in run.exe.

We use the above method to launch-and-forget a long-running application; the user executes the parent which launches the child, logs off and goes home. Bear in mind too that the child inherits the environment from the parent but it's not a bad idea to make any required environment settings in the child just to make sure.

Hope this helps some.
 
Old 12-14-2007, 12:59 PM   #5
horacioemilio
Member
 
Registered: Dec 2007
Posts: 61

Original Poster
Rep: Reputation: 15
it worked !

thanks


Quote:
Originally Posted by tronayne View Post
I think you may need to launch your child process(es) like this
Code:
...
nohup ./run.exe inputfile >> /dev/null 2>>/dev/null &
...
That is, without piping the output of the parent or run.exe into ssh in the parent process -- do the pipe in run.exe instead, passing any necessary arguments to it from the parent
Code:
...
nohup ./run.exe ${ARG1} ${ARG2} inputfile >> /dev/null 2>>/dev/null &
...
You need to handle your output to ssh or any log files in run.exe.

We use the above method to launch-and-forget a long-running application; the user executes the parent which launches the child, logs off and goes home. Bear in mind too that the child inherits the environment from the parent but it's not a bad idea to make any required environment settings in the child just to make sure.

Hope this helps some.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Put a process in background and logout esasse Linux - Newbie 11 03-28-2012 02:53 PM
code that send a process to the background feetyouwell Programming 5 11-29-2010 03:20 PM
send process to the background ugp Programming 3 02-08-2006 10:28 PM
is there a system call to send process to run in the background? feetyouwell Programming 4 10-01-2004 04:58 AM
send process to background radam Linux - General 6 07-13-2004 04:33 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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