On Saturday 02 November 2002 03:07 am, JM wrote:
> Hey guys in need some programming help
> If i have have a program and i want it to run as a
> background process on bootup, how do i do that?
> is this on the programming side or is it on the linux
> config side?
run it with an ampersand at the end. that runs it in
background mode. e.g., if you need to do something
like "rm -rf /tmp/*" to run in the background, you
can say:
rm -rf /tmp/* &
you can also call the daemon function (man 3 daemon)
inside your C/C++ program (use the matching function in
your language of choice if you're not using C/C++).
that will detach your program from the controlling terminal
and run in the background.
so you can do it both ways. i prefer the & style because
it's more flexible. if you want to, you can run it in
foreground mode for debugging. and if you need it in
background, you just stick the & at the end of the
command line.
depending on your needs, you might want to allow both.
for instance, sendmail can process just one message or
it can run as a daemon. you can call it with -bd to make
it run as a daemon and without -bd (and with the right
other options) to make it run one time and process just
one email.
another example, sshd runs as a daemon by default, but
if you need to debug problems, then you can run it
with -d and then it doesn't call the daemon(...) function.
tiger
--
Gerald Timothy Quimpo tiger*quimpo*org gquimpo*sni-inc.com tiger*sni*ph
Veritas liberabit vos.
... region del sol querida, Perla del Mar de Oriente,
nuestro perdido Eden! ...
_
Philippine Linux Users Group. Web site and archives at http://plug.linux.org.ph
To leave: send "unsubscribe" in the body to [EMAIL PROTECTED]
Fully Searchable Archives With Friendly Web Interface at http://marc.free.net.ph
To subscribe to the Linux Newbies' List: send "subscribe" in the body to
[EMAIL PROTECTED]