SlackwareThis Forum is for the discussion of Slackware Linux.
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 wanted some service coming up on login, so I put them into rc.local and chmod'd it. Well, they don't load.
Maybe I need to tell rc.M or a more hierarchical script to source it? Of maybe rc.local should be being read, and I've goodfed up my system a little?
If rc.local has been chmodded to +x then it should run fine at boot time.
The only thing I can think of (for a fairly clean system...) is that the programs you not in the boot $PATH, or if you are referencing them by their full location (/opt/bin/whatever) there is a problem with the service itself.
oh yes, I got it now. hese service are in my $PATH, but not the bootpath. AS rc.local gets sourced real early, my .bashrc hasn't had a chance to export the paths these services lie in. That's the explanation.
I suppose I¡ll just launch them from .bashrc then, like everything else.
Or change my boot path, I'll have to look for it.
That's not quite it, actually. Your .bashrc is only read and implemented when you yourself log in. If you had multiple users, each with their .bashrc or .bash_profile, none of them would be active except for the specific user, and only after they had logged in. The system itself doesn't care what is in your path, as you've discovered, only what's in its path.
In rc.local I always make sure to use absolute pathnames to make sure I don't run into this problem.
Yes, more or less .bashrc is read everytime you launch the bash interpreter, and for your user. Take into account stuff launched from rc.local will run as root unless you launch it with sudo (or a similar tool) or the program explicitly changes to another user (many daemons do that and drop privileges to be more secure).
Hi, yes, thanks for the comments.
putting them in .bashrc didn't feel right, you're right Poetics.
So I went into rc.S and changed the bootpath. Guess what, it didn't work.
Wow, does rc.local get sourced early or what?
But from the replies, it seems that the absolute path manner is the one to use.
Many thanks!
rc.local is the *last* init script to run, just before login is called. It's the proper place to put any extras you need to run during bootup. Normally you shouldn't alter the other scripts unless you really know what you are doing and why. Many extra program packages include a routine which writes an entry to rc.local which gets run during each boot-up. The routines usually look somthing like this:
Code:
if [ -x /etc/rc.d/extra-service ] ; then
. /etc/rc.d/extra-service
fi
The referenced script might look something like this:
Code:
#!/bin/sh
/path/to/extra_service
Having a setup like this allows you to enable or disable the extra_service program simply by making the /etc/rc.d/extra-service script executable or non-executable.
The best way to ensure that the service gets started properly is to run it using the full path.
I have the following in my rc.local, but it doesn't seem to work. Am I doing something wrong?
#!/bin/sh
#
# /etc/rc.d/rc.local: Local system initialization script.
#
# Put any local startup commands in here. Also, if you have
# anything that needs to be run at shutdown time you can
# make an /etc/rc.d/rc.local_shutdown script and put those
# commands in there.
What runlevel are you using?
Does the program run if you run it manually after logging in in runlevel 3?
Make sure there is a blank line after the line with the command.
You may need to put '&' after the command to background it.
What runlevel are you using?
Does the program run if you run it manually after logging in in runlevel 3?
Make sure there is a blank line after the line with the command.
You may need to put '&' after the command to background it.
I'm using runlevel 3.
I will check for the blank line.
And I will also try using "&" after the command. Thanks. Here again is my rc.local:
Code:
#!/bin/sh
#
# /etc/rc.d/rc.local: Local system initialization script.
#
# Put any local startup commands in here. Also, if you have
# anything that needs to be run at shutdown time you can
# make an /etc/rc.d/rc.local_shutdown script and put those
# commands in there.
/usr/local/slimserver/slimserver.pl --daemon
What runlevel are you using?
Does the program run if you run it manually after logging in in runlevel 3?
Make sure there is a blank line after the line with the command.
You may need to put '&' after the command to background it.
I made sure there is a blank line after the command.
I've checked and the same command works in runlevel 3 before I manually start x. Still, rc.local does execute the command.
I will try the "&" next. I assume the command should be:
What runlevel are you using?
Does the program run if you run it manually after logging in in runlevel 3?
Make sure there is a blank line after the line with the command.
You may need to put '&' after the command to background it.
Everything is as it should be according to your questions. I did get rc.local to echo a message, so I know the file is working.
I've tried the command with and without the "&" at the end. Here is my rc.local as it now stands:
Code:
#!/bin/sh
#
# /etc/rc.d/rc.local: Local system initialization script.
#
# Put any local startup commands in here. Also, if you have
# anything that needs to be run at shutdown time you can
# make an /etc/rc.d/rc.local_shutdown script and put those
# commands in there.
/usr/local/slimserver/slimserver.pl --daemon &
That this doesn't work is no big deal, but I'm curious none the less why it doesn't.
Everything is as it should be according to your questions. I did get rc.local to echo a message, so I know the file is working.
I've tried the command with and without the "&" at the end. Here is my rc.local as it now stands:
Code:
#!/bin/sh
#
# /etc/rc.d/rc.local: Local system initialization script.
#
# Put any local startup commands in here. Also, if you have
# anything that needs to be run at shutdown time you can
# make an /etc/rc.d/rc.local_shutdown script and put those
# commands in there.
/usr/local/slimserver/slimserver.pl --daemon &
That this doesn't work is no big deal, but I'm curious none the less why it doesn't.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.