![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Running script on remote machine | vickylife | UNIX for Advanced & Expert Users | 3 | 11-17-2008 05:45 PM |
| To invoke a script on a remote machine | sam_roy | SUN Solaris | 5 | 10-08-2008 12:31 PM |
| Checking the status of the script on remote machine | nua7 | Shell Programming and Scripting | 3 | 07-24-2008 02:41 AM |
| how to execute a script on remote machine | balireddy_77 | Shell Programming and Scripting | 4 | 09-27-2006 07:45 PM |
| leave a process running in a remote machine | pbasil | UNIX for Dummies Questions & Answers | 3 | 03-15-2006 10:04 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
running script in background on remote machine
Hi there
I have a script which is running a remote command on hundreds of boxes, it takes around 5 minutes to return an output from this command and because i am running this all from a central box, it goes off to each box in my for loop sequentially meaning that my script will wait for output before moving to the next machine so as an example i will use the command `sleep 30`. I tried putting an ambersand into the script to no avail...the output on my central server still sits and waits for each box to sleep for 30 seconds rather than sending the command off to a box, letting that box deal with it and moving onto the next box with no delay an example Code:
for hostname in $list do /usr/ucb/echo -n "$hostname - " ssh $hostname 'sleep 30 &' done output ....ZZZZzzzzz ![]() Code:
myserver1 - (waits 30 seconds then..) myserver2 - .. .. .. Is there a way to do this ?? |
|
||||
|
First of all, you'll want the "ssh" command to return. So you add the ampersand to the ssh command, not (only) the sleep command.
Second problem: as the ssh returns, the remote server might terminate the process. Use "nohup" to fix that. ssh $hostname 'nohup sleep 30 &' & How's that do? |
|
||||
|
mmm, didnt work,
I added the & to the nohup command first and the central script still waited 30 secnonds before moving on to the next box. Adding the additional & to the overall ssh command, did the same thing but just put it all in the background on the central server, so i didnt get any output ....still took just as long any other ideas? |
|
||||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|