LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-05-2011, 09:14 AM   #1
rvaede
LQ Newbie
 
Registered: Feb 2011
Posts: 20

Rep: Reputation: 0
nohup help


I need help adding a nohup command in this command line:
su - rhx12 -c "/rhythx/rhythx/bin start /rhythx/rhyth"
When I execute the script using root on the command line it works fine.
But, when I reboot the server the process doesn't start.

This script will go into the etc/init.d and rc2.d directory.

#!/bin/bash
case $1 in
start)
su - rhx12 -c "/rhythx/rhythx/bin start /rhythx/rhythx"
;;
stop)
su - rhx12 -c "/rhythx/rhythx/bin stop /rhythx/rhythx"
;;
*)
echo "should be command stop or start"
;;
esac

Last edited by rvaede; 03-09-2011 at 06:58 AM.
 
Old 03-05-2011, 10:30 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
First, please don't double-post. Choose only one forum that you think best matches your topic. I'm responding to this one because it's a scripting question.

Second, please use [code][/code] tags around your code, to preserve formatting and to improve readability.

Code:
case $i in
What is $i? It's not defined anywhere in the script, so I can't imagine it would work at all. Do you perhaps mean $1?
 
Old 03-05-2011, 11:21 AM   #3
rvaede
LQ Newbie
 
Registered: Feb 2011
Posts: 20

Original Poster
Rep: Reputation: 0
Yes thats correct, it should be $1.
I am at home and I don't have access to the work network so I entered the script from memory.
 
Old 03-07-2011, 12:14 PM   #4
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
Please edit your post to put the code in a Code block, as suggested above. It will make your post easier to read, & that will get you more, better, & faster help.
 
Old 03-08-2011, 06:42 AM   #5
rvaede
LQ Newbie
 
Registered: Feb 2011
Posts: 20

Original Poster
Rep: Reputation: 0
Thanks I was able to fix this.
 
Old 03-08-2011, 07:17 AM   #6
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
2 of us, one Senior Member & one Moderator, have nicely asked you to edit your post which started this thread.
  1. Why have you not complied w/ these polite requests?
  2. Do you need help finding the "Edit" button?
  3. Is my earlier link to info on Code blocks not clear?
 
Old 03-09-2011, 06:59 AM   #7
rvaede
LQ Newbie
 
Registered: Feb 2011
Posts: 20

Original Poster
Rep: Reputation: 0
I fixed the code using the edit link.
The link you provided did not help find the solution.
But, its a useful link.

regards
 
Old 03-09-2011, 07:14 AM   #8
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Quote:
This script will go into the etc/init.d and rc2.d directory.
If that is true, the script will be running as the root user, so you don't need to use su - preceding the command.

The command wouldn't run because it is an interactive command expecting a password entered, which won't happen when running as a startup script.

Be careful with automated scripts such as cron scripts for example. For cron scripts you aren't attached to a terminal, so you can't get input from stdin. There is no stdout, so either redirect output to /dev/null or a log file.
Also, nohup isn't used for scripts already running in the background.

Look at the skeleton file in /etc/init.d/. It is a model of what a script in init.d should look like. You left out the headers that inserv and chkconfig use.

In rc2.d/ you should have a properly named link to the script in init.d/. Don't put scripts in their.

You might want to read the man pages for insserv, chkconfig and init.d.

(note: some distro's don't use chkconfig.)

Last edited by jschiwal; 03-09-2011 at 07:17 AM.
 
  


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 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
nohup sycamorex Linux - General 4 01-08-2008 05:49 PM
To use or not to use nohup entz Linux - Server 9 04-07-2007 04:52 PM
problem with nohup command and nohup file size vbseeker Linux - General 1 09-17-2006 11:36 AM
help on nohup vinayuh Linux - General 3 07-22-2005 12:24 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:32 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration