LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 11-08-2012, 02:52 AM   #1
r_s
Member
 
Registered: May 2009
Distribution: slackware, fedora, ubuntu
Posts: 94

Rep: Reputation: 21
magic with nohup


I have two files file1 and file2. Within file2 I am running a daemon in the background as user user1.
And I am executing this file2 from within file1, running file1 as root. This creates two process one being executed as root and the other as user1. However if add a nohup before the invocation of the daemon in file2, it shows only one process being run as user1.

A little more explanation.

file1
Code:
#!/bin/bash
file2
file2
Code:
#!/bin/bash
sudo -u user1 java daemon &
and now ps aux gives..
Code:
root   file2
user1  java daemon &
however adding a nohup to file2, like
Code:
nohup sudo -u user1 java daemon &
shows just one process running as user1.
 
Old 11-08-2012, 04:13 AM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,226

Rep: Reputation: 2022Reputation: 2022Reputation: 2022Reputation: 2022Reputation: 2022Reputation: 2022Reputation: 2022Reputation: 2022Reputation: 2022Reputation: 2022Reputation: 2022
That's because nohup disconnects from the calling process; that's what its supposed to do. Hence, the calling script immediately runs to completion.
You can use a few echo statements to see the difference, or add 'set -xv' thus
Code:
#!/bin/bash
set -xv
 
  


Reply

Tags
linux, nohup, process


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] nohup, but no nohup.out -- how to? smc2 Programming 1 10-11-2010 08:13 AM
problem with nohup command and nohup file size vbseeker Linux - General 1 09-17-2006 11:36 AM
Using Partition Magic and Boot Magic to install Linux zathrus MEPIS 4 01-14-2006 08:24 PM
Partition Magic/Boot magic and Slackware. adam1835 Linux - Newbie 5 01-11-2006 11:46 AM
help on nohup vinayuh Linux - General 3 07-22-2005 12:24 PM


All times are GMT -5. The time now is 07:41 AM.

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