The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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
Stoping & starting the cron daemon othman SCO 0 04-30-2007 10:23 AM
Starting MySQL daemon unispace UNIX for Dummies Questions & Answers 15 12-14-2006 09:40 PM
process starting count_zero OS X (Apple) 2 08-09-2004 03:39 PM
capture the process id when starting a background process jleavitt Shell Programming and Scripting 10 04-04-2002 08:04 AM
Daemon process s_chordia High Level Programming 2 01-17-2002 02:09 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-23-2008
nitinshukla nitinshukla is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 2
How to starting process as daemon using ssh command?

Hello,

I need to run a command on remote Linux using the ssh command from my local machine. I am able to execute the command on remote machine using ssh but it's behaving strangely.

The command is supposed to start a daemon process on remote linux box and the control should return back to me but strangely this does not happen. The command works properly (i.e. starts the daemon process) when I ssh into remote linux box and type the command on console.

Here is how I give command on remote linux machine after sshing into the box.

$ /usr/local/bin/fatality.sh --email=nitins.shukla@gmail.com --log_dir=/tmp/fatality &
[1] 23274
$

This works fine and the process runs as daemon in background.

But when I try to run this command on same Linux box from my local machine, the process does not start as daemon and runs in background. Here's how I give the command from my linux machine

$ ssh root@remotelinux "/usr/local/bin/fatality.sh --email=nitins.shukla@gmail.com --log_dir=/tmp/fatality \"&\""

The control does not return back to me. Logging on the remote linux box I find that the process is running but not as daemon process in background.

Can anyone help how I should pass the command to ssh start the process as daemon process so that the control returns back to me.

Note both the time I am using same user account i.e. root to log on remote linux machine.

Any help is deeply appreciated.

Thank n Regards,
Nitin
  #2 (permalink)  
Old 06-23-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,259
Code:
ssh -f root@remotelinux .....
Quote:
\"&\"
This should not be written like that, more like
Code:
.... &"
ie. the ampersand does not have to be in extra double quotation marks nor must it be escaped with a backslash.
  #3 (permalink)  
Old 06-23-2008
nitinshukla nitinshukla is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 2
How to starting process as daemon using ssh command?

The -f option makes the ssh command on my local linux box to run in background which is not what I intend want to do. I want the process on remote linux (that I am invoking to throught ssh command) to start in background on the remote linux box.
  #4 (permalink)  
Old 06-23-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,259
Yep, you got an ssh process on your local machine left, which is not needed anymore, yep. On the remote machine it will run without problems and when sending the command you will be back on your prompt.
I got no better idea atm If I come up with one, I will post it.
  #5 (permalink)  
Old 06-25-2008
jonesgeek jonesgeek is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 2
Same problem

I am having the same problem. I am having cruise control kick off a script that deploys to a dev machine nightly and start up the service, yet the ssh process still runs in the background causing cruise control to hang.

I am thinking of trying to run the daemon in a screen so that I can detach from the console, but not sure how to do that in a script, I've only used screen from the command line using the ctrl commands.

Any thoughts?
  #6 (permalink)  
Old 06-26-2008
jonesgeek jonesgeek is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 2
point stdin and stdout to /dev/null

I found this on google groups: Starting a daemon with ssh - comp.unix.admin | Google Groups

ssh server 'program </dev/null >/dev/null 2>&1 &'

that redirects the stdin to /dev/null, the stdout to /dev/null, and the stderr to stdout

This worked for me so that the remote execution kicked off the daemon and didn't wait around for output.

Will
Closed Thread

Bookmarks

Tags
linux, solaris

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:15 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0