For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > October 2004 > run program at start up









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author run program at start up
Jimmie

2004-10-20, 8:57 pm

Hi,
So I created a program called foo, and i want to run foo when linux
starts up, how do i go about doing this? Im using slackware.

Jimmie Barnett
Fletcher Glenn

2004-10-20, 8:57 pm



Jimmie wrote:
> Hi,
> So I created a program called foo, and i want to run foo when linux
> starts up, how do i go about doing this? Im using slackware.
>
> Jimmie Barnett


You need to make an entry in one of the /etc/rc?.d directories where ?
is a single digit integer.

--

Fletcher Glenn

Jim Cochrane

2004-10-20, 8:57 pm

In article <cf6cc6cc.0410201546.ff4501@posting.google.com>, Jimmie wrote:
> Hi,
> So I created a program called foo, and i want to run foo when linux
> starts up, how do i go about doing this? Im using slackware.
>
> Jimmie Barnett


One common method - read up on /etc/init.d and /etc/rc.d, directories that
hold scripts that are run on start-up.

--
Jim Cochrane; jtc@dimensional.com
[When responding by email, include the term non-spam in the subject line to
get through my spam filter.]
Jem Berkes

2004-10-20, 8:57 pm

> So I created a program called foo, and i want to run foo when linux
> starts up, how do i go about doing this? Im using slackware.


Very easy with slackware, just insert the command into
/etc/rc.d/rc.local

Make sure full paths are specified to everything.

--
Jem Berkes
http://www.sysdesign.ca/
Jim Cochrane

2004-10-21, 3:58 am

In article <Xns9588C907C52A3jbuserspc9org@130.179.16.24>, Jem Berkes wrote:
>
> Very easy with slackware, just insert the command into
> /etc/rc.d/rc.local


Except if the command is a binary executable, in which case you'll need to
write a script to run the command and put the script into .../rc.local
..

--
Jim Cochrane; jtc@dimensional.com
[When responding by email, include the term non-spam in the subject line to
get through my spam filter.]
Jem Berkes

2004-10-21, 3:58 am

>>> So I created a program called foo, and i want to run foo when linux
>
> Except if the command is a binary executable, in which case you'll
> need to write a script to run the command and put the script into
> .../rc.local .


Why do you say that? rc.local itself is a shell script (you'll see
#!/bin/sh at the top). You can run other shell scripts or binaries directly
out of there.

--
Jem Berkes
http://www.sysdesign.ca/
Jim Cochrane

2004-10-21, 3:58 am

In article <Xns9588CDA727A5jbuserspc9org@130.179.16.24>, Jem Berkes wrote:
>
> Why do you say that? rc.local itself is a shell script (you'll see
> #!/bin/sh at the top). You can run other shell scripts or binaries directly
> out of there.
>


Oops, I was thinking about the /etc/rc?.d directories and forgot that
rc.local is a script, not a directory. Of course, one can start up a
binary executable by inserting instructions into rc.local to start it up.
I meant that one cannot put a binary into, e.g., /etc/rc4.d/ as a means to
have it started automatically. Instead, a script must be used to start it
up - either rc.local or a fresh script that gets placed into the
appropriate /etc/rc?.d directories.

Sorry about the confusion.

--
Jim Cochrane; jtc@dimensional.com
[When responding by email, include the term non-spam in the subject line to
get through my spam filter.]
Lew Pitcher

2004-10-21, 3:58 am

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Fletcher Glenn wrote:
>
>
> Jimmie wrote:
>
>
>
> You need to make an entry in one of the /etc/rc?.d directories where ?
> is a single digit integer.


Sorry, but slackware doesn't have /etc/rc?.d directories. It has one directory
called /etc/rc.d, and scripts in that directory. The scripts are called
rc.0, rc.M, rc.gpm, rc.keymap, rc.netdevice, etc.

To the OP, add your program to the /etc/rc.d/rc.local script

- --
Lew Pitcher

Master Codewright & JOAT-in-training | GPG public key available on request
Registered Linux User #112576 (http://counter.li.org/)
Slackware - Because I know what I'm doing.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBdx/JagVFX4UWr64RAjxQAJ9AsI/tQAkPKfa24eHHwISEGx/E+wCfZPSz
wn9pCduo2wrtmN/NA9IuF4Y=
=QK+q
-----END PGP SIGNATURE-----
Heiko

2004-10-21, 8:57 am

Jim Cochrane wrote:

> I meant that one cannot put a binary into, e.g., /etc/rc4.d/ as a means to
> have it started automatically. Instead, a script must be used to start it
> up - either rc.local or a fresh script that gets placed into the
> appropriate /etc/rc?.d directories.


The OP uses slackware, which uses BSD-style init. This means /etc/rc?.d
directories are not used, nor present on a slackware system.

Heiko
Jim Cochrane

2004-10-21, 4:03 pm

In article <41779eb9$0$568$e4fe514c@news.xs4all.nl>, Heiko wrote:
> Jim Cochrane wrote:
>
>
> The OP uses slackware, which uses BSD-style init. This means /etc/rc?.d
> directories are not used, nor present on a slackware system.
>
> Heiko


Thanks for the correction.

Does that mean that the only way on a Slackware system to have init
start a process when the system starts up is to modify rc.local to do it?

--
Jim Cochrane; jtc@dimensional.com
[When responding by email, include the term non-spam in the subject line to
get through my spam filter.]
Lew Pitcher

2004-10-21, 4:03 pm

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jim Cochrane wrote:
> In article <41779eb9$0$568$e4fe514c@news.xs4all.nl>, Heiko wrote:
>
>
>
> Thanks for the correction.
>
> Does that mean that the only way on a Slackware system to have init
> start a process when the system starts up is to modify rc.local to do it?


No.

A Slackware sym could
a) change /etc/rc.d/rc.local, or
b) change the appropriate, already existing /etc/rc.d/rc.* file, or
c) add a sysV style rc file, or
d) change /etc/inittab



- --
Lew Pitcher
IT Consultant, Enterprise Data Systems,
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed are my own, not my employers')
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFBeA6RagVFX4UWr64RAlZfAKDg5FuNzTwA
RrhsxMrtJ3nJKsL0PQCg2JB+
sty2ISOtXgmHW4kQ793tBiw=
=O3rD
-----END PGP SIGNATURE-----
Måns Rullgård

2004-10-21, 4:03 pm

Jim Cochrane <jtc@shell.dimensional.com> writes:

> In article <41779eb9$0$568$e4fe514c@news.xs4all.nl>, Heiko wrote:
>
> Thanks for the correction.
>
> Does that mean that the only way on a Slackware system to have init
> start a process when the system starts up is to modify rc.local to do it?


Recent slackware versions have a /etc/rc.d/rc.sysvinit script that
runs things in /etc/rc?.d for compatibility.

Incidentally most distributions using sysv-style scripts also have
/etc/rc.local, to make it simpler to add minor things to run at
startup, without requiring an entire rc?.d script.

--
Måns Rullgård
mru@mru.ath.cx
Jim Cochrane

2004-10-22, 3:57 pm

In article <yw1xk6tju9yh.fsf@mru.ath.cx>, Måns Rullgård wrote:
> Jim Cochrane <jtc@shell.dimensional.com> writes:
>
>
> Recent slackware versions have a /etc/rc.d/rc.sysvinit script that
> runs things in /etc/rc?.d for compatibility.


Thanks to you, and Lew, for filling me in on this.

> Incidentally most distributions using sysv-style scripts also have
> /etc/rc.local, to make it simpler to add minor things to run at
> startup, without requiring an entire rc?.d script.


Yes, I knew that, but I didn't know (if I'm taking your implication
correctly) that rc.local was a BSD-style construct.

Thanks.

--
Jim Cochrane; jtc@dimensional.com
[When responding by email, include the term non-spam in the subject line to
get through my spam filter.]
Rich Teer

2004-10-22, 3:57 pm

On Fri, 22 Oct 2004, Jim Cochrane wrote:

> Yes, I knew that, but I didn't know (if I'm taking your implication
> correctly) that rc.local was a BSD-style construct.


Yes, rc.local is indeed from BSD.

--
Rich Teer, SCNA, SCSA, author of "Solaris Systems Programming"

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-group.com/rich
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com