How to starting process as daemon using ssh command?

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to starting process as daemon using ssh command?
# 1  
Old 06-23-2008
How to starting process as daemon using ssh command?


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/ --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/ --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,
# 2  
Old 06-23-2008
ssh -f root@remotelinux .....

This should not be written like that, more like
.... &"

ie. the ampersand does not have to be in extra double quotation marks nor must it be escaped with a backslash.
# 3  
Old 06-23-2008
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  
Old 06-23-2008
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 Smilie If I come up with one, I will post it.
# 5  
Old 06-25-2008
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  
Old 06-26-2008
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.

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Daemon process

I wish to make a process run in the background, but only one instance of it, and not many, so when the program is loaded, it has to check whether another instance of the same program is running and if so to exit. How do I do this ? (4 Replies)
Discussion started by: sundaresh
4 Replies

2. Shell Programming and Scripting

[solved] Process ssh command in while loop

I have a script that reads a file containing a list of server names. It's suppose to loop through the list of names and execute a command on the remote server using ssh. It processes the ssh command for the first server in the list and then exits. Here's the code: #!/bin/bash ... (2 Replies)
Discussion started by: westmoreland
2 Replies

3. Shell Programming and Scripting

[KSH/Bash] Starting a parent process from a child process?

Hey all, I need to launch a script from within 2 other scripts that can run independently of the two parent scripts... Im having a hard time doing this, if anyone knows how please let me know. More detail. ScriptA (bash), ScriptB (ksh), ScriptC (bash) ScriptA, launches ScriptB ScirptB,... (7 Replies)
Discussion started by: trey85stang
7 Replies

4. Shell Programming and Scripting

SSH starting nohup'd process - not exiting

I'm trying to ssh into a remote server, run a script which may or may not start a nohup'd background process and then exit leaving the process running on the remote server. I'm looping through a number of servers to do this but the script hangs as soon as it comes to a server where the remote... (3 Replies)
Discussion started by: Steve_H
3 Replies

5. SCO

Stoping & starting the cron daemon

Hi We are running SCO ver 5. Recently the cron daemon stopped running on its own. How do I find out why? How do I restart/stop it? I typed cron but it didn't work. Will rebooting it do the trick or can I manually start and stop the cron daemon? Please help. Thanks & Regards. (0 Replies)
Discussion started by: othman
0 Replies

6. UNIX for Dummies Questions & Answers

Starting MySQL daemon

I'm running a FreedBSD server with mysql 4.1. When I start mysqld via the command: # /usr/local/bin/safe_mysqld --user=mysql it starts the mysql db (I know because the websites are running off of it) but does not return to a prompt, it will let me type but will not respond unless I restart... (15 Replies)
Discussion started by: unispace
15 Replies

7. Linux

daemon process

how i will write the daemon process,if any body have sample daemon process send me. (1 Reply)
Discussion started by: suresh_rupineni
1 Replies

8. Shell Programming and Scripting

capture the process id when starting a background process

Hello all, How do I start a background process and save the process id to a file on my system. For example %wait 5 & will execute and print the process id. I can't figure out how to get it to a file. I've tried: > filename 0>filename 1>filename. Any assistance is most appreciated. Thanks, Jim... (10 Replies)
Discussion started by: jleavitt
10 Replies

9. Programming

What is a daemon process?

This is gonna seem really silly to almost evryone here - but I need to know : what is a daemon process? Thanks (6 Replies)
Discussion started by: Kanu77
6 Replies

10. Programming

Daemon process

Hi, I have to write a daemon process, which performs certain operations in the background. Now since it performs operations in the background, it should not display anything to the standard output. The problem is that it still displays, text on standard output. Can anyone tell me (it is... (2 Replies)
Discussion started by: s_chordia
2 Replies
Login or Register to Ask a Question

Featured Tech Videos