• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 220
  • Last Modified:

How to write a program runs in boot time??

Hi,

I would like to create a program which runs in boot time...how can I do so?



Xenia
0
xenia27
Asked:
xenia27
  • 3
  • 3
  • 2
  • +2
3 Solutions
 
lynxlupodianCommented:
Nothing special is needed in the program itself, you just add it to the boot level to execute, when it's finished. This procedure varies from distro to distro, but is nothing hard.

Although, you usually execute things after the boot level.
0
 
EinarThCommented:
1) write the program

2) start it via one of the bootup scripts in /etc/rc.d or via /etc/inittab

The question isn't really overly clear tho....
0
 
wesly_chenCommented:
Hi,

> program which runs in boot time
Say the program you create: /usr/local/bin/testprgm

Add
/usr/local/bin/testprgm
into

/etc/rc.d/rc.local     for (Fedora/RedHat)
/etc/rc.d/boot.local  (SuSE)
/etc/init.d/local  (Debian) (If not there, create one with first line "#!/bin/sh" )

Regards,

Wesly
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
avizitCommented:
Your  need might be different ,
you can have two things

1. Program to run during boot
2. program to run when you login

for 1) i.e  for the program to run during boot , you can use what wesly have said
for 2) i.e for the program to run when you login , read

http://www.hk8.org/old_web/linux/run/ch04_15.htm

just wanted to let you know , cos most of time you want something to run only when you login , say for example to set some environment variables etc .If that is so you may not want to run it everytime you boot.
0
 
xenia27Author Commented:
If I want to make my program run in background constantly, what should I do in my main?
0
 
avizitCommented:
then you would probably want to write a daemon , http://www.linuxprofilm.com/articles/linux-daemon-howto.html

0
 
wesly_chenCommented:
Yes, daemon in Unix/Linux is like the "service" in Windows, it resides in memory after it runs.
Daemon can start at boot time as the method I mentiooned.

Wesly
0
 
xenia27Author Commented:
Thanks for the information...Is there more web site I can study??
0
 
avizitCommented:
0
 
xenia27Author Commented:
Thanks for your helps~~~  ^^
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 3
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now