Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am confused on how to start my Daemon C program at boot-up. The program runs as a Daemon OK when I satrt it from command shell, but now I want it to start up every time at boot-up. I have searched for the last week on how to do this and there many confusions on how this is done - easily and simply? I am running Unbuntu 11.10 and don't really want to put in the the Ubuntu Startup files - it works but only after the user has logged-on. I want it to start-up even if the user has not logged in - just like apache2 server that I have which starts up after boot-up - plain and simple.

What I have found is that I need to create a init script and put in in the /etc/init.d/ directory but am not sure how to do this properley? My Daemon is executable and located at /usr/local/bin/myDaemon and to run it from the command shell I simply use /usr/local/bin/myDaemon to run it?

Can someone please show me a simple basic exapmple script that I can use to get me started?

share|improve this question

migrated from Nov 29 '11 at 14:24

This question came from our site for professional and enthusiast programmers.

Don't forget to call the daemon library function in your program.

Then, create a /etc/init.d/yourdaemon script taking /etc/init.d/skeleton as a model (init script vary from distribution to distribution).

You could also create a crontab entry for your daemon, using @reboot as the time specification.

share|improve this answer
You also need to symlink your /etc/init.d/yourdaemon script into an appropriate place in the SysV RC hierarchy (the init manpage on your system will usually tell you which runlevels are for what, and finding the right spot within a runlevel is usually pretty self-explanatory. Note that Ubuntu has started using Upstart ( in place of the traditional SysV init scripts and best practices are different there. – voretaq7 Nov 29 '11 at 18:59

Other options outside of setting it up in /etc/init.d:


@reboot /path/to/exec

Most systems will have /etc/rc.local - which executes the commands in it on system boot.

share|improve this answer

Your Answer


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