![]() |
|
|||||||
| Notices |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Guest
Posts: n/a
|
auto-running a script as daemon
I have a perl script to monitor various bits of my server, which I run as
root: /usr/local/sbin/monitor.pl & That works fine, but I'd really like to start it automatically on reboot. How would I organise that? -- Tony van der Hoff | mailto: Buckinghamshire, England |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Re: auto-running a script as daemon
"Tony van der Hoff" <> wrote in message
news:gemini.jsl2w1005t6v4052s.news@nospam.vanderho ff.org... >I have a perl script to monitor various bits of my server, which I run as > root: /usr/local/sbin/monitor.pl & > > That works fine, but I'd really like to start it automatically on reboot. > How would I organise that? > 1. Drop the script into /etc/init.d. 2. Look at /etc/inittab and find what run level you're starting at, the line will look something like this: id:x:initdefault: where x is the value you want. 3. Put a symlink to /etc/init.d/monitor.pl into /etc/rc.d/rcx.d where again x is the number from inittab. The symlink should be somthing like Snnmonitor.pl where nn are two digits defining the order of the services to start relative to the other services in that run level. Please note that the directory names and positions vary with each distribution so you may need to change things slightly. -- Geoff |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Re: auto-running a script as daemon
> 1. Drop the script into /etc/init.d.
> 2. Look at /etc/inittab and find what run level you're starting at, the > line will look something like this: > id:x:initdefault: > where x is the value you want. > > 3. Put a symlink to /etc/init.d/monitor.pl into /etc/rc.d/rcx.d where > again x is the number from inittab. The symlink should be somthing like > Snnmonitor.pl where nn are two digits defining the order of the services > to start relative to the other services in that run level. You may also need to do a similar job on a script to stop the process when your system is being shut down. |
|
|
|
#4 |
|
Guest
Posts: n/a
|
Re: auto-running a script as daemon
In article <gemini.jsl2w1005t6v4052s.news@nospam.vanderhoff.o rg>,
Tony van der Hoff <> wrote: >I have a perl script to monitor various bits of my server, which I run as >root: /usr/local/sbin/monitor.pl & > >That works fine, but I'd really like to start it automatically on reboot. >How would I organise that? It varies from distro to distro... Eg. Debian look in /etc/init.d for a file called skeleton - this is a bash script, so copy this to eg /etc/init.d/monitorMyStuff and edit to start your own thing, then run update-rc.d monitorMyStuff defaults and it'll create all the right symbolic links in /etc/rc?.d. See the man page for update-rc.d to work out how to get it to start before or after various other things (if needed) and note that it will get called with a parameter of start or stop, depending on the machine booting or shutting down. Gordon |
|
|
|
#5 |
|
Guest
Posts: n/a
|
Re: auto-running a script as daemon
On 5 Dec at 16:11 "Geoffrey Clements"
<> wrote in message <4756c9d8$> > "Tony van der Hoff" <> wrote in message > news:gemini.jsl2w1005t6v4052s.news@nospam.vanderho ff.org... > > I have a perl script to monitor various bits of my server, which I run > > as root: /usr/local/sbin/monitor.pl & > > > > That works fine, but I'd really like to start it automatically on > > reboot. How would I organise that? > > > > 1. Drop the script into /etc/init.d. 2. Look at /etc/inittab and find what > run level you're starting at, the line will look something like this: > id:x:initdefault: where x is the value you want. > > 3. Put a symlink to /etc/init.d/monitor.pl into /etc/rc.d/rcx.d where > again x is the number from inittab. The symlink should be somthing like > Snnmonitor.pl where nn are two digits defining the order of the services > to start relative to the other services in that run level. > Thanks, Geoff; I'm sure I knew that once, but my memory must be slipping... > Please note that the directory names and positions vary with each > distribution so you may need to change things slightly. > No, it was all as you describe. Thanks again. -- Tony van der Hoff | mailto: Buckinghamshire, England |
|
|
|
#6 |
|
Guest
Posts: n/a
|
Re: auto-running a script as daemon
On 5 Dec at 16:25 Gordon Henderson <gordon+usenet@drogon.net> wrote in
message <fj6jdf$20if$1@energise.enta.net> > In article <gemini.jsl2w1005t6v4052s.news@nospam.vanderhoff.o rg>, Tony van > der Hoff <news_0711@vanderhoff.org> wrote: > > I have a perl script to monitor various bits of my server, which I run > > as root: /usr/local/sbin/monitor.pl & > > > > That works fine, but I'd really like to start it automatically on > > reboot. How would I organise that? > > It varies from distro to distro... Eg. Debian look in /etc/init.d for a > file called skeleton - this is a bash script, so copy this to eg > /etc/init.d/monitorMyStuff and edit to start your own thing, then run Thanks, Gordon; my distro doesn't have that; I can only see things like "Program Files", and "My Documents and Settings". Um, not really , but I'm running Mandriva, which has its roots in red hat,and what Geoff described was ideal. Thanks for replying, anyway. Cheers, Tony -- Tony van der Hoff | mailto:news_0711@vanderhoff.org Buckinghamshire, England |
|
|
|
#7 |
|
Guest
Posts: n/a
|
Re: auto-running a script as daemon
On 5 Dec at 16:11 "Geoffrey Clements"
<> wrote in message <4756c9d8$> > "Tony van der Hoff" <> wrote in message > news:gemini.jsl2w1005t6v4052s.news@nospam.vanderho ff.org... > > I have a perl script to monitor various bits of my server, which I run > > as root: /usr/local/sbin/monitor.pl & > > > > That works fine, but I'd really like to start it automatically on > > reboot. How would I organise that? > > > > 1. Drop the script into /etc/init.d. 2. Look at /etc/inittab and find what > run level you're starting at, the line will look something like this: > id:x:initdefault: where x is the value you want. > > 3. Put a symlink to /etc/init.d/monitor.pl into /etc/rc.d/rcx.d where > again x is the number from inittab. The symlink should be somthing like > Snnmonitor.pl where nn are two digits defining the order of the services > to start relative to the other services in that run level. > Thanks, Geoff; I'm sure I knew that once, but my memory must be slipping... > Please note that the directory names and positions vary with each > distribution so you may need to change things slightly. > No, it was all as you describe. Thanks again. -- Tony van der Hoff | mailto: Buckinghamshire, England |
|
|
|
#8 |
|
Guest
Posts: n/a
|
Re: auto-running a script as daemon
On 5 Dec at 16:25 Gordon Henderson <gordon+usenet@drogon.net> wrote in
message <fj6jdf$20if$1@energise.enta.net> > In article <gemini.jsl2w1005t6v4052s.news@nospam.vanderhoff.o rg>, Tony van > der Hoff <news_0711@vanderhoff.org> wrote: > > I have a perl script to monitor various bits of my server, which I run > > as root: /usr/local/sbin/monitor.pl & > > > > That works fine, but I'd really like to start it automatically on > > reboot. How would I organise that? > > It varies from distro to distro... Eg. Debian look in /etc/init.d for a > file called skeleton - this is a bash script, so copy this to eg > /etc/init.d/monitorMyStuff and edit to start your own thing, then run Thanks, Gordon; my distro doesn't have that; I can only see things like "Program Files", and "My Documents and Settings". Um, not really , but I'm running Mandriva, which has its roots in red hat,and what Geoff described was ideal. Thanks for replying, anyway. Cheers, Tony -- Tony van der Hoff | mailto:news_0711@vanderhoff.org Buckinghamshire, England |
|
|
|
#9 |
|
Guest
Posts: n/a
|
Re: auto-running a script as daemon
Tony van der Hoff wrote:
> On 5 Dec at 16:25 Gordon Henderson <gordon+usenet@drogon.net> wrote in > message <fj6jdf$20if$1@energise.enta.net> > >> In article <gemini.jsl2w1005t6v4052s.news@nospam.vanderhoff.o rg>, Tony van >> der Hoff <news_0711@vanderhoff.org> wrote: >>> I have a perl script to monitor various bits of my server, which I run >>> as root: /usr/local/sbin/monitor.pl & >>> >>> That works fine, but I'd really like to start it automatically on >>> reboot. How would I organise that? >> It varies from distro to distro... Eg. Debian look in /etc/init.d for a >> file called skeleton - this is a bash script, so copy this to eg >> /etc/init.d/monitorMyStuff and edit to start your own thing, then run > > Thanks, Gordon; my distro doesn't have that; I can only see things like > "Program Files", and "My Documents and Settings". > > Um, not really , but I'm running Mandriva, which has its roots in red hat,> and what Geoff described was ideal. > If your distro is RedHat-like, there is a bit of help: - there's no example script, but its easy enough to find something suitable in /etc/rc.d/init.d, copy it and edit it. At a minimum it should have sections that implement start, stop, status and restart requests. The vs-ftp or sshd scripts are reasonable starting points. - use the "chkconfig" command to set up the symlinks in /etc/rc.d/rc.n (where 'n' is the run level) that are used to start or stop the service whenever the runlevel is changed - use the "service" command to start, stop and restart the service or query its status. chkconfig and service can only be run as root. -- martin@ | Martin Gregorie gregorie. | Es***, UK org | |
|
|
|
#10 |
|
Guest
Posts: n/a
|
Re: auto-running a script as daemon
Tony van der Hoff wrote:
> On 5 Dec at 16:25 Gordon Henderson <gordon+usenet@drogon.net> wrote in > message <fj6jdf$20if$1@energise.enta.net> > >> In article <gemini.jsl2w1005t6v4052s.news@nospam.vanderhoff.o rg>, Tony van >> der Hoff <news_0711@vanderhoff.org> wrote: >>> I have a perl script to monitor various bits of my server, which I run >>> as root: /usr/local/sbin/monitor.pl & >>> >>> That works fine, but I'd really like to start it automatically on >>> reboot. How would I organise that? >> It varies from distro to distro... Eg. Debian look in /etc/init.d for a >> file called skeleton - this is a bash script, so copy this to eg >> /etc/init.d/monitorMyStuff and edit to start your own thing, then run > > Thanks, Gordon; my distro doesn't have that; I can only see things like > "Program Files", and "My Documents and Settings". > > Um, not really , but I'm running Mandriva, which has its roots in red hat,> and what Geoff described was ideal. > If your distro is RedHat-like, there is a bit of help: - there's no example script, but its easy enough to find something suitable in /etc/rc.d/init.d, copy it and edit it. At a minimum it should have sections that implement start, stop, status and restart requests. The vs-ftp or sshd scripts are reasonable starting points. - use the "chkconfig" command to set up the symlinks in /etc/rc.d/rc.n (where 'n' is the run level) that are used to start or stop the service whenever the runlevel is changed - use the "service" command to start, stop and restart the service or query its status. chkconfig and service can only be run as root. -- martin@ | Martin Gregorie gregorie. | Es***, UK org | |
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
< Windows Help - MS Office Help - Hardware Support >
| New To Site? | Need Help? |