LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   rc.local wont start my program at boot (https://www.linuxquestions.org/questions/linux-newbie-8/rc-local-wont-start-my-program-at-boot-4175446620/)

Xtrato 01-21-2013 12:12 PM

rc.local wont start my program at boot
 
Im having trouble getting a command to run when the computer has booted. Im using the rc.local file to try and do this. The 3 lines i have added to the file are below:

Code:

kismet_server > /root/logfile.txt &
sleep 10s
python /scripts/kismetstatus.py &

Basically i want the kismet_server application to run at startup and any output it produces to be sent to a text file at /root/logfile.txt. This program runs indefinitely. After that has started the kismetstatus.py script runs which is used to check the file etc..

The problem is strange because the logfile.txt is created but nothing is written to it. If i enter the commands manually when the computer is on it all works perfectly fine. It just dosn't seem to work when attempting to start it automatically at boot.

I have tried adding these lines to both /etc/rc.local and /etc/init.d/rc.local and both produce the same results.

Is there any reason this may be happening? or an alternative way i can make a program start at boot time.

Thankyou in advance for your help.

jpollard 01-21-2013 12:19 PM

What system are you trying to do this on?

If it is a current Fedora, it is entirely possible that the network you are trying to listen on doesn't exist at the time it tries to start.

There are NO guarantees that rc.local actually runs at the proper time. Fedora now being systemd based, tries to start everything at once. So unless you add explicit chains to the "after:" lists to try to force it... it will run before the network is even initialized.

TroN-0074 01-21-2013 12:22 PM

I believe each distro works differently, so what distribution are you working with?
some distros now use systemd and think systemd doesnt use rc.local at all. I am no 100% in this hopefully somebody here with more experience can see your post.

Xtrato 01-21-2013 12:48 PM

Thank you for the reply's. It is a Debian based distro that running on a Raspberry PI computer. I have a print statement in the python script and i can see that is is infact starting when the computer starts.

If the network interface dosn't have time to start i would still expect to see logfile.txt contain the error that the interface diddnt start.

It is just the problem of the logfile.txt not being written to in any way, even though executing the exact same command manually works perfectly fine.

0siris 01-21-2013 01:16 PM

Is it possible that the Kismet server is, in fact, logging to its default location instead of to the logfile.txt that you want it to use?

I think that would be the final proof that the problem is the order things are starting up.

chrism01 01-21-2013 07:39 PM

Unless the program daemonizes itself, it'll terminate when rc.local (actually the process running rc.local) finishes.
Try prefixing with 'nohup' as well.

Xtrato 01-22-2013 02:46 AM

Quote:

Originally Posted by chrism01 (Post 4875018)
Unless the program daemonizes itself, it'll terminate when rc.local (actually the process running rc.local) finishes.
Try prefixing with 'nohup' as well.

Thanks for the suggestion! I will give it a try when i get back home tonight.


All times are GMT -5. The time now is 04:42 PM.