LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Am I missing something when it comes to /etc/rc.local? (http://www.linuxquestions.org/questions/linux-general-1/am-i-missing-something-when-it-comes-to-etc-rc-local-627844/)

Jongi 03-13-2008 02:46 PM

Am I missing something when it comes to /etc/rc.local?
 
My understanding is that if I put a command in /etc/rc.local, it should run at boot. However take a look at my /etc/rc.local and look at the output of ps aux straight afrer boot and you will see that hellanzb.py is not running

Code:

[root:~#] cat /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

/usr/bin/hellanzb.py -D
touch /var/lock/subsys/local

Code:

[root:~#] ls /usr/bin/hellanzb.py
/usr/bin/hellanzb.py

I've even tried moving hella to below the line beginning with touch and it still doesn't load.

Code:

[root:~#] ps aux | grep hella
root      2757  0.0  0.0  82236  752 pts/0    S+  23:16  0:00 grep hella

During the boot sequence, if I press Alt-D, I can see right at the end that there is a message that pops up. Where can I look under /var/log to find out what that message is?

Code:

[root:~#] cat /var/log/boot.log
[root:~#] cat /var/log/messages | grep hella

This is on F8 x86_64

hasanatizaz 03-13-2008 03:43 PM

if you want to load scripts during BOOT you can put scripts in /etc/rc.d/rc.[the init level you want] make sure its executable...

Jongi 03-14-2008 12:01 AM

Didn't work as well

Code:

[root:~#] cat /etc/rc.d/rc.5
/home/user/helladaemon

Code:

[root:~#] cat /home/user/helladaemon
#!/bin/bash
/usr/bin/hellanzb.py -D
[root:~#] ls -la /home/user/helladaemon
-rwxrwxr-x 1 jongi jongi 36 2008-03-14 06:47 /home/user/helladaemon


Tinkster 03-14-2008 01:09 AM

And ls -l /usr/bin/hellanzb.py ?


Cheers,
Tink

konsolebox 03-14-2008 01:12 AM

first make sure that /etc/rc.local is really able to run the file. add this inside the file
Code:

exec >/home/user/log
echo "trying to start /home/user/helladaemon"
[ -x /home/user/helladaemon ] && echo "/home/user/helladaemon seems to be not executable in this environment but lets try"
( exec /home/user/helladaemon ; ) &
exec >/dev/stdout

then check /home/user/log

billymayday 03-14-2008 02:23 AM

Does what you are trying to do if you run the copmmand in rc.local manually?

Jongi 03-14-2008 11:47 AM

Code:

[root:~#] ls -la /usr/bin/hellanzb.py
-rwxr-xr-x 1 root root 1942 2008-02-15 19:05 /usr/bin/hellanzb.py

Code:

[root:~#] ls -la /etc/rc.local
lrwxrwxrwx 1 root root 13 2008-02-15 00:01 /etc/rc.local -> rc.d/rc.local

Code:

[root:~#] cat /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
exec >/home/user/log
echo "trying to start /home/user/helladaemon"
[ -x /home/user/helladaemon ] && echo "/home/user/helladaemon seems to be not executable in this environment but lets try"
( exec /home/user/helladaemon ; ) &
exec >/dev/stdout

Code:

[root:~#] cat /home/user/log
[root:~#]


PTrenholme 03-14-2008 11:58 AM

Perhaps you need a disown command after you start the process so it won't terminate when the rc.local script terminates.

Without a disown, script termination automatically sends a "kill" signal to any of its children. Note that, unless you use an argument, the disown command should be the next command that the script runs since, by default, it "disowns" the last prior executed command.

Jongi 03-14-2008 12:09 PM

ah ha. I suspected something like that.

so have it look like this:

Code:

touch /var/lock/subsys/local
/usr/bin/hellanzb.py -D
disown

EDIT: Nope, didn't do the trick

Jongi 03-14-2008 01:54 PM

I've "cheated" and just added the command to Autostarted Applications in XFCE. It feels like such a second choice solution though.

AlucardZero 03-14-2008 01:55 PM

put in someone's crontab. @reboot /usr/bin/hellanzb.py ?

hasanatizaz 03-14-2008 05:30 PM

Jongi
are u setting 777 i mean are u giving the executable permission ?
it needs to begin with S --> inorder to start
and then the process number -- > 97 for example | inorder to initiate the process with the priority as a number.


S97filename | make sure its 7xx

PTrenholme 03-14-2008 10:26 PM

Quote:

Originally Posted by geniushasan (Post 3088974)
Jongi
are u setting 777 i mean are u giving the executable permission ?
it needs to begin with S --> inorder to start
and then the process number -- > 97 for example | inorder to initiate the process with the priority as a number.


S97filename | make sure its 7xx

Wouldn't that advice only apply if the Python program was in /etc/rc.d//init.d and being started as a service? The question was "How to run the script from /etc/rc/rc.local, although starting it as a service is not a bad idea.

If the OP wants to set it up as a service, a look at the scripts in /etc/rc.d/init.d should make the general process clear, and creating a link to the service script from /etc/rd.d/rc.5 in the format suggested above is relatively straight forward.

Note: The use of /etc/rc.d/ rather than /etc is, I believe, distribution specific, so the actual location of your service initiation scripts my differ from the location I specified. But they shouldn't be too hard to find.

konsolebox 03-14-2008 11:59 PM

You should simply find the way to start your /etc/rc.d/rc.local. Check your other /etc/rc.d/* files and find clues on how they are started. Perhaps changing the execution permissions or pointing a link to the file in a runtime directory will do the trick.

Jongi 03-16-2008 11:07 AM

Quote:

Originally Posted by geniushasan (Post 3088974)
Jongi
are u setting 777 i mean are u giving the executable permission ?
it needs to begin with S --> inorder to start
and then the process number -- > 97 for example | inorder to initiate the process with the priority as a number.


S97filename | make sure its 7xx

I have no clue what it is you mean


All times are GMT -5. The time now is 11:51 PM.