LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 05-09-2012, 06:44 AM   #1
nandha.v
LQ Newbie
 
Registered: Nov 2009
Posts: 2

Rep: Reputation: 0
stdout & stderr background process questions


Hi Everyone,

Even I know that this was posted long back , I couldn't find answer for this. Anyone help me to log the stdout and stderr of a background process which starts using start-stop-daemon.

Thanks a lot.
 
Old 05-10-2012, 02:53 PM   #2
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 5,770
Blog Entries: 4

Rep: Reputation: 697Reputation: 697Reputation: 697Reputation: 697Reputation: 697Reputation: 697
In general:

nohup process >logfile 2>&1 &

The nohup tells it not to hang up when a terminal closes and is likely not necessary if this is started in the background since no terminal is there. The >logfile redirects standard output to logfile. The 2>&1 redirects standard error to standard output which was already redefined as logfile. You can substitute the path and name of the file you want to log to for logifle in the above. The final ampersand (&) tells it to background the process (which again may not be necessary if you're starting it from a background process.
 
Old 05-11-2012, 01:29 AM   #3
nandha.v
LQ Newbie
 
Registered: Nov 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks for your response Mensa and it works out well.

Also, I want to use stdout and stderr redirection with the command "start-stop-daemon". Please explain the possibility for this.
 
Old 05-11-2012, 07:47 AM   #4
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 5,770
Blog Entries: 4

Rep: Reputation: 697Reputation: 697Reputation: 697Reputation: 697Reputation: 697Reputation: 697
I don't know of a command called "start-stop-daemon".

Which distribution and version of Linux are you using?

What does "which start-stop-daemon" output?

What does "file $(which start-stop-daemon)" output?

In general though for most programs you can redirect stdout/stderr as I indicated even if the program takes input. If for example start-stop-daemon expected you to put a daemon (for example sshd) you might try:

start-stop-daemon sshd >/var/log/sshd_log 2>&1

Note that I am not saying it can be used that way because as I noted I don't know what this command is. Assuming it isn't a script someone there wrote it may have a man page or an info page (or both). Typing "man start-stop-daemon" or "info start-stop-daemon" might give you more details including what the command allows to be redirected (or what it doesn't).

Last edited by MensaWater; 05-11-2012 at 08:16 AM.
 
Old 05-11-2012, 08:03 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,512
Blog Entries: 27

Rep: Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174
I vaguely recall that start-stop-daemon is a function defined in the boot scripts library on some systems, maybe in /etc/init.d/functions.
 
  


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 On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to change stdin, stdout & stderr in u-boot to ethernet from serial jynthms Linux - Newbie 1 04-01-2009 09:34 AM
Perl stderr&stdout redirect question Fredde87 Programming 5 03-26-2009 04:43 AM
shell script: how to send stdout one place & stderr another? BrianK Programming 8 09-21-2007 06:57 AM
Shell script - stdout & stderr to terminal and file jantman Linux - Software 1 12-07-2006 04:34 PM
stdout for a background process GOLDF1NG3R Linux - General 3 11-14-2001 01:10 PM


All times are GMT -5. The time now is 01:37 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration