LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-04-2002, 11:39 AM   #1
SchwipSchwap
Member
 
Registered: Aug 2002
Distribution: Suse8.0, Mandrake, Knoppix
Posts: 92

Rep: Reputation: 15
Unhappy Start a daemon/program at boot


Im really

i wanna start the daemon lircd at boot
and then the program irexec

i tried it at:
/etc/inid.d/boot.local the program started, but
the daemon failed with permission denied

Where can i start the daemon

THX SchwipSchwap
 
Old 08-04-2002, 12:11 PM   #2
MartBrooks
Member
 
Registered: May 2002
Location: London
Distribution: Debian
Posts: 388

Rep: Reputation: 31
Start again. What /exactly/ did you add to this file? What was the error message? Where did you see this error message?

Regards
 
Old 08-04-2002, 12:39 PM   #3
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,578

Rep: Reputation: 191Reputation: 191
Can you start the deamon manually or you get the same error?
 
Old 08-04-2002, 01:47 PM   #4
SchwipSchwap
Member
 
Registered: Aug 2002
Distribution: Suse8.0, Mandrake, Knoppix
Posts: 92

Original Poster
Rep: Reputation: 15
i can start the daemon manually as root

i added at /etc/init.d/boot.local:

/dev/lircd
/usr/local/bin/irexec /home/user/irexec

at startup i get error /dev/lircd cant start daemon
permission denied

--> irexec failed too: cant find socket

manually i can start both and it works
 
Old 08-04-2002, 03:41 PM   #5
SchwipSchwap
Member
 
Registered: Aug 2002
Distribution: Suse8.0, Mandrake, Knoppix
Posts: 92

Original Poster
Rep: Reputation: 15
the lircd daemon has to be added at runlevel3

do i have to write the skripts myself to add the daemon?!

or is there an easier way
 
Old 08-04-2002, 06:46 PM   #6
SchwipSchwap
Member
 
Registered: Aug 2002
Distribution: Suse8.0, Mandrake, Knoppix
Posts: 92

Original Poster
Rep: Reputation: 15
Problem solved

cp /tmp/lirc-0.6.3pre3/contrib/lirc.suse6.2 /etc/init.d/lirc
cd /etc/init.d/rc3.d
ln -s ../lirc S80lirc
ln -s ../lirc K80lirc
cd /etc/init.d/rc5.d
ln -s ../lirc S80lirc
ln -s ../lirc K80lirc

http://www.suse.com/us/support/howto/fb/index.html#t5
 
Old 01-18-2006, 09:35 AM   #7
bogoda
Member
 
Registered: Jan 2006
Posts: 32
Blog Entries: 2

Rep: Reputation: 15
Quote:
Originally Posted by SchwipSchwap
Problem solved

cp /tmp/lirc-0.6.3pre3/contrib/lirc.suse6.2 /etc/init.d/lirc
cd /etc/init.d/rc3.d
ln -s ../lirc S80lirc
ln -s ../lirc K80lirc
cd /etc/init.d/rc5.d
ln -s ../lirc S80lirc
ln -s ../lirc K80lirc

http://www.suse.com/us/support/howto/fb/index.html#t5
Hello SchwipSchwap,

I sow your question posted in 2003.

I am now confuse with daemon program.

I have a daemon program written in c++.

But i donot know how to set that run at system boot up.

Some people say that we can script as Daemon.

If possiable how it can do.

Please if u can help me.

I konw very few things about daemon and scripts.

Thank you.
 
Old 01-18-2006, 11:27 AM   #8
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
To start your program at boot, like for instance any ftp daemons or http daemons, then you'll need to
create a script in /etc/init.d
Have a look at the scripts that are already there. They are not very hard to understand.
They simply provide a way to:
-start the daemon
-stop it
-restart it (==stop + start)
-...

Basically, your program then becomes a "service" and you can start it by:
/sbin/service <name_of_script_in_/etc/init.d> start
likewise for stop/restart/status.
See also "man service".

In such scripts, it's also typical to define a "pid-file". This file stores the Process ID (unique number that identifies a running program) in a file, usually somewhere in /var/run/...
If you do so, you can question your service's status too. Checking the status will simply check if the PID file is there or not. If it is, then that indicates that the program is still running, so it'll get the status "running" or "ok". If not, then you get status "stopped".

Another issue is the so-called runlevel. When you boot, run in single user mode, run in normal multi-user mode, graphical multi user mode, shutdown the machine, etc, the machine is in fact in different runlevels (states). See "man init" for details on your system's runlevels.
Services, like the ones in /etc/init.d, are typically only started when your computer goes into one or more runlevels. For instance, you probably don't want to start your program whenever the computer goes to the shutdown runlevel (because it's then shutting everything down). Likewise for the boot runlevels (0 and 1 typically).
In fact, most daemons should only run in multi-user runlevels, typically levels 3, 4 and 5 and in some cases also in single user mode (runlevel 2 typically).
To make your script run in certain runlevels, you need to use "chkconfig".
See "man chkconfig" for details.
In short, your /etc/init.d/something script should have a line at the beginning telling chkconfig the default runlevels and giving it a certain number in the starting order (for instance the script that starts httpd will run after the network configuration because it has a higher number). You should thus probably give your program a pretty high number. For shutting down, the order of the scripts is reversed automatically (so high numbered scripts are shut down first).

After you've added your script to chkconfig's control, you can use commands like:
/sbin/chkconfig --level 345 <your_service>
to run it in levels 3, 4 and 5.
<your_service> is the name of your script in /etc/init.d.
 
Old 01-19-2006, 10:27 PM   #9
bogoda
Member
 
Registered: Jan 2006
Posts: 32
Blog Entries: 2

Rep: Reputation: 15
Question Few things to know Daemon

First of all thank you very much for your discription about Daemon script.

I done the work as explained.

But I have some problems.

There are some commands that i cannot understand.

[ -e /proc/apm ] || /sbin/modprobe apm &>/dev/null

CONFIG=/etc/sysconfig/apdm


Are those lines nessary.

Also how can i create file in /var/run/... to store my pid.

I can manually run the daemon how can i make it run on the booting time.

I set chkconfig: 0123

But i could not see that is running.

Thank you
 
Old 01-20-2006, 03:00 AM   #10
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Perhaps my explanation wasn't very clear. If you want to run the daemon, a few "rules of thumb":
-use chkconfig --levels 345. Starting up the daemon when your system (briefly) is in runlevel 0 or 1 probably won't do what you want.
-Second of all, for the chkconfig changes to be used, you need to actually change the runlevel to one of the levels for which the daemon is supposed to run. So, you'll need to reboot your machine or use the "telinit" program or something.
-Thirdly, you're not supposed to take the scripts in /etc/init.d literally. I said that you consider them as examples.
The lines
Quote:
Originally Posted by 03000176
[ -e /proc/apm ] || /sbin/modprobe apm &>/dev/null
CONFIG=/etc/sysconfig/apdm
that you mentioned actually configure a kernel module for apm (battery power monitoring), if /proc/apm (a pseudo-file, representing a part of the kernel) doesn't exist (in other words, if the module isn't already loaded). Your daemon probably doesn't need to set up this module (the apmd daemon's script, /etc/init.d/apmd, already sets it up for you), so you shouldn't use those lines in your script.

-To create a file in /var/run, you must be the "root" user. The daemon script in /etc/init.d should in any case be run as root (most daemons need to be started as root, because they allocate ports with portnumbers < 1024, the so-called "privileged ports"). If your daemon doesn't do that, it's possible that you shouldn't be using a daemon at all. For process id files (PID files in short), you can simply create them via "touch" or by "echo" of your pid into the file.
You should also have a look at the /etc/init.d/functions script, which provides some useful functions, like killproc() (for killing a certain process, even if you don't know it's PID).

So, please describe what exactly your daemon program is supposed to do.
 
Old 01-20-2006, 03:39 AM   #11
bogoda
Member
 
Registered: Jan 2006
Posts: 32
Blog Entries: 2

Rep: Reputation: 15
Wink Daemon my Program

hello timmeke,

Thank you verymuch for your reply.

I am sorry for my low knowledge about linux.

Because i am new for it.

We suppose to run a program (Daemon) at system bootup time to run another java program.

That java program is responsible for calculating free spaces of given program.

So I want run a Daemon program to do above task.

I want to konw how i can write a daemon program as a script.

Writing a java program will done by my friend.

So can you give any suggetion for daemon.


Thank you very much for your help again.
 
Old 01-20-2006, 06:41 AM   #12
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
No problem. I'm relatively new to Linux myself.
But after a while, you'll get the hang of it, just like me.

Unfortunately, your explanations of the program are still somewhat unclear to me.
For instance, what do you mean with "free spaces"?
Why does the daemon need to run at startup (boot)?
Isn't it enough to start it just before you login? Or even when one particular user logs in?
What does the Java program do and why does it require the other program to run first?
 
Old 01-20-2006, 12:10 PM   #13
bogoda
Member
 
Registered: Jan 2006
Posts: 32
Blog Entries: 2

Rep: Reputation: 15
Smile My Daemon Program

Thank you for reply,

This is what all about.

We hope to develop strage area network(SAN) as a project.

On system boot time we want to run the daemon program and get the free spases of the local hard disk drives in our net work.

So free space calculating done by java program.

I want to create a daemon program to execuate that java program at system boot up.

Then after login user can see his free space.

I think you can get rough idea about what we are going to do.

If you can help me Thank full to u.

 
Old 01-23-2006, 03:13 AM   #14
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
I don't know much about SANs, but they're just a bunch of network hard disks, no?
To use them, you'll need to mount them, possibly by some disk volume management software.
So, your "daemon" will need to run after that software.
If you find the /etc/init.d/ script that launches this management software, find it's place in the order
of launch at boot (chkconfig number) and you should launch your program afterwards (higher number).

If you don't have such a disk management program, you should consider getting one. It would make system configuration and maintenance a lot easier, probably.

You shouldn't launch your daemon if the disk management soft isn't loaded. So only run your program in the same runlevels (most likely 3, 4 and 5 - maybe 2 as well).

I do have some questions for you:
-Can't you use a command line tool like "df" to get the disk free space, once the disks have been mounted?
Using Java to calculate disk space seems a bit much (Linux, just like most OSs, keep track of disk space for
you, so you don't need to write a program that does the math).
-How do you want to report the available disk space to the users?
When they login? In plain text? Via a web interface? Send them a mail whenever free disk space is lower than
a certain number of bytes/megabytes/gigabytes?
-Doesn't the disk management software provide some kind of interface (for instance a graphical user interface
or web interface) that allows you to monitor the disk's space? And can't you allow the users to use that
interface? Or does this give the users also the possibility to mess up the disk configuration?
 
Old 01-23-2006, 10:23 AM   #15
bogoda
Member
 
Registered: Jan 2006
Posts: 32
Blog Entries: 2

Rep: Reputation: 15
HI timemeke,

Disk management program don by one of my friend.

Therefore i also don't know how he going to show it.

my task is to create a daemon to run that program.

I tried it many ways included in forums.

but could not catch it.

Evean it is better to write a script to run on the background from booting process.
So can u explain a simple daemon program script and how can i make it to run.
It is better evean to execute a C program.
I am now in deep trouble.

Thannk u.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to start my GUI program by a daemon? oldh Linux - Software 3 08-05-2005 03:04 PM
How to have 'at' daemon start automatically on boot TrulyTessa Linux - Newbie 4 12-13-2004 12:12 PM
Start program in daemon mode from cgi-bin Xa! Programming 1 12-01-2004 12:00 AM
Getting a daemon to start at boot cmfarley19 Linux - General 5 12-14-2002 03:54 PM
How do I start ntp daemon at boot? jkcunningham Linux - Software 5 07-19-2002 09:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration