ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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?
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.