|
|||||||||
| Ubuntu Ubuntu is a complete desktop Linux operating system, freely available with both community and professional support. |
unix and linux commands - unix shell scripting |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
How can I automatically start a daemon at boot time.
Hi masters,
I am still learning trades in kernel. I am trying to learn the basic of daemon programming. Can any one tell me how can I start a daemon automatically during boot up. I will be greatfull if anyone post some example code to the above task. Also what are the other things that you must know when you try daemon programming? Can any one help me? |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
a basic unix daemon does the following: fork close all filedescriptors (stdout,stderr, etc) chdir / signal handeling (sighup, sigterm etc) while do stuff sleep(xx) done (example in C: daemon.c) Red Hat example on how to install startup scripts: to start a deamon at system startup in redhat you need a init script. it should be placed in /etc/init.d example of init script : Code:
# chkconfig: 3 99 1 # description: my daemon case "$1" in 'start') /usr/local/bin/mydaemon ;; 'stop') pkill mydaemon ;; 'restart') pkill -HUP mydaemon ;; esac the first line will tell chkconfig to start the daemon in run level 3 with priority 99 and kill it as priority 1 when server shutdowns. to install the startup script use the following: chkconfig --add ./scriptabove Now it will start when the server boots. to start it right away use: service <name_of_initfile> start Hope this helps somewhat! Last edited by s93366; 12-18-2008 at 04:38 AM.. |
| Sponsored Links | ||
|
|
|
#3
|
||||
|
||||
|
|
|
#4
|
||||
|
||||
|
How does it work on Solaris?
Hi s93366,
Thanks so much for the excellent tutorial. I works great on Linux environment. However, When I was trying it on Solaris environment, it doesn't work since there's no chkconfig on Linux. Do you have any idea on how to make it work on Solaris? I am new to Linux/Unix, and is learning Linux/Unix. Any help will be greatly appreciated. |
| Sponsored Links | ||
|
|
![]() |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Database can't start automatically on solaris | Sachin Vaidya | Solaris | 2 | 02-27-2008 11:12 PM |
| How to start Oracle database automatically | greg0320 | Solaris | 3 | 03-30-2005 05:46 PM |
| start a process at boot up time | vtran4270 | UNIX for Advanced & Expert Users | 1 | 12-08-2002 07:31 PM |
| getting postfix tyo start automatically | kmgrady01 | UNIX for Dummies Questions & Answers | 2 | 05-21-2002 03:18 AM |
| Disable routed daemon at boot time???? | rrivas | UNIX for Dummies Questions & Answers | 2 | 04-09-2002 12:53 PM |
|
|