2

I'm trying to start a script on bootup on a Ubuntu Server 10.10 machine.

The relevant parts of my rc.local look like this:

/usr/local/bin/python3.2 "/root/Advantage/main.py" >> /startuplogfile
exit 0

If I run ./rc.local from /etc everything works just fine and it writes the following into /startuplogfile:

usage: main.py [--loop][--dry]

for testing purposes this is exactly what needs to happen. It won't write anything to startuplogfile when I reboot the computer. I'd venture to guess that the script is not started when rc.local is run at bootup.

I verified that rc.local is started with a 'touch /rclocaltest' in the file. As expected the directory is created.

I've tested rc.local with another python script that simple creates a file in / and prints to the /startuplogfile. From terminal and after reboot, it works just fine.

my execution bits are set like this:

-rwxrwxrwx 1 root root    4598 2011-04-22 19:09 main.py

I have absolutely no idea why this happens and I tried everything that I could think of to remedy the problem. Any ideas on what could be causing this, I'm totally out of ideas.

EDIT: I forgot to mention that I only login to this machine over ssh. I'm not sure that makes difference since rc.local is executed before login as far as I know.

EDIT: I noticed that this post is a little chaotic so let me sum it up:

  • I verified that rc.local is called on bootup
  • If rc.local is manually called everything works as expected
  • Permissions are set correctly
  • A testing python script works as expected on bootup with rc.local
  • My actual python script will only run if rc.local is manually called, not on bootup

2 Answers 2

3

try to redirect stderr and stdout into the /startuplogfile like this :

/usr/local/bin/python3.2 "/root/Advantage/main.py" >> /startuplogfile 2>&1

you will see if an error occurs

Sign up to request clarification or add additional context in comments.

3 Comments

I will try that right now. Could you do me a big favor and explain the syntax? I'm intrigued.
This helped tremendously I now have a much clearer picture of what's going on. Sure enough, the error was coming from the python script. Thank you very much
stderr (where errors are logged) is the 2. stdout (where the standard output is logged and by) is the 1, the one you can put in a file. When writing 2>&1 you redirect stderr into stdout.
3

You definitely don't want to have that script world-writable. You're trying to automatically run it as root on bootup, but since it's world-writable anyone could change the script to do anything at all - that's a massive security hole.

1 Comment

You're right and thank you. I just went all out to try to make this work, once that happens I will start locking things down!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.