0

I would like to find out how to write Python code which sets up a process to run on startup, in this case level two.

I have done some reading, yet it has left me unclear as to which method is most reliable on different systems. I originally thought I would just edit /etc/inittab with pythons fileIO, but then I found out that my computers inittab was empty.

What should I do? Which method of setting something to startup on boot is most reliable? Does anyone have any code snippets lying around?

5
  • What version of Linux are you using? Commented Dec 9, 2012 at 4:05
  • Ubuntu 10.10. I think the empty inittab is probably because the box is a VPS, and hence runs inside openVZ. Commented Dec 9, 2012 at 4:11
  • I don't have a 10.10 instance around to test on, but I think that's using upstart to manage what's started at boot. You should be able to create a script in /etc/init. Take a look at the upstart docs Commented Dec 9, 2012 at 4:23
  • I was hoping to create a script that would work on all versions of linux. Not just Ubuntu Commented Dec 9, 2012 at 7:39
  • I'm not sure if there will ever be one standard way to do startup scripts, but upstart seems to be the standard on many recent linux distros. Older versions of RedHat don't use it, but RHEL 6 has it. So you should be able to get lots of Linux distros if you go the upstart route. Here's a post that goes into a little more detail on python daemons Commented Dec 10, 2012 at 3:40

1 Answer 1

0

I may as well answer my own question with my findings.

On Debian,Ubuntu,CentOS systems there is a file named /etc/rc.local. If you use pythons' FileIO to edit that file, you can put a command that will be run at the end of all the multi-user boot levels. This facility is still present on systems that use upstart.

On BSD I have no idea. If you know how to make something go on startup please comment to improve this answer.

Archlinux and Fedora use systemd to start daemons - see the Arch wiki page for systemd. Basically you need to create a systemd service and symlink it. (Thanks Emil Ivanov)

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

1 Comment

Archlinux and Fedora use systemd to start daemons - see the Arch wiki page for systemd. Basically you need to create a systemd service and symlink it.

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.