Take the 2-minute tour ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

This question has been asked quite a few times before but I didn't seem to get it working using the existing information.

My Pi runs Raspbian. I have a Python script named dnscheck.py which loops forever.

I need it to run at boot. I know I have to create a .sh file containing something like

sudo python dnscheck.py &

What I don't know is where this file should be or if it should contain anything else. I know about the init.d folder, but seeing the skeleton example I imagine there should be a simpler way to do this simple task.

share|improve this question
add comment

2 Answers

up vote 6 down vote accepted

If you want to control the process with commands like start, stop, restart etc using the skelton script and altering it for your purposes might be the best option.

If you just want the process to start and that's it, you might consider just putting the command, as you wrote it in your question, into the /etc/rc.local. (I don't have my RPi at hand, but I read online that there is an 'exit 0' line in there, you should put your command above this line)

share|improve this answer
    
It worked! I must add that setting the permissions for the script and rc.local back to 755 (read/write/execute) is a must. Not sure if both need this setting, but it worked for me. Thanks a lot for the help! –  Vlad Schnakovszki Dec 27 '12 at 0:07
add comment

Move your script (we will save it to the file dnscheck) to /etc/init.d/, and set the permissions so it can be ran: chmod 755 /etc/init.d/dnscheck

Then create the symbolic links by running update-rc.d /etc/init.d/dnscheck defaults

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.