start background process on host server

J

Jenkins

I want to start a perl pgm in the background on my hosts web server as a
stand-alone process. I only have ftp access. What I've done, so far, is:

1) created the actual background perl script, named fetchmyweather.pl. This
script retrieves a string from an noaa weather station and inserts it into a
mysql db, then sleeps for an hour, and repeats indefinitely. Nothing heavy
and it's ok with my provider.

2) created a second perl script, named 'startfetchmyweather.pl', that only
contains this command: exec ('fetchmyweather.pl') or print STDERR "couldn't
exec foo: $!";

3) created an html page that contains this: <!--#exec
cmd="cgi-bin/startfetchmyweather.pl"-->

I'm not totally sure about this, but I thought if I called the html page, it
would execute 'startfetchmyweather.pl' in the foreground, which would spawn
'fetchmyweather.pl' as an unattached process on the host server. That would
allow me to close my browser without killing the 'fetchmyweather.pl' script.

First, I'm not sure if the process is actually getting started. It doesn't
seem to be since it should immediatelly fetch a string, insert it into the
table and then go to sleep for the first time. The first string is not
getting inserted.

Second, how can I monitor the process other than checking the mysql db for
new records every hour (not that I'd check it every hour...)?

Thanks,
doug
 
G

Ga Mu

Jenkins said:
I want to start a perl pgm in the background on my hosts web server as a
stand-alone process. I only have ftp access. What I've done, so far, is:

1) created the actual background perl script, named fetchmyweather.pl. This
script retrieves a string from an noaa weather station and inserts it into a
mysql db, then sleeps for an hour, and repeats indefinitely. Nothing heavy
and it's ok with my provider.

2) created a second perl script, named 'startfetchmyweather.pl', that only
contains this command: exec ('fetchmyweather.pl') or print STDERR "couldn't
exec foo: $!";

3) created an html page that contains this: <!--#exec
cmd="cgi-bin/startfetchmyweather.pl"-->

I'm not totally sure about this, but I thought if I called the html page, it
would execute 'startfetchmyweather.pl' in the foreground, which would spawn
'fetchmyweather.pl' as an unattached process on the host server. That would
allow me to close my browser without killing the 'fetchmyweather.pl' script.

First, I'm not sure if the process is actually getting started. It doesn't
seem to be since it should immediatelly fetch a string, insert it into the
table and then go to sleep for the first time. The first string is not
getting inserted.

Second, how can I monitor the process other than checking the mysql db for
new records every hour (not that I'd check it every hour...)?

Thanks,
doug

Sounds like you want to run a perl script every hour to fetch some
information and deposit it in a dB. Why not use a cron job that runs
your script every hour..? A crontab entry like this:

0 * * * * /path/to/your/script.pl

will run your script every hour on the hour.

One possible problem with your approach is that the uid/gid that your
web server runs under may not have adequate permission to launch a
detached process. (Since you don't specify the O/S or web server
software, it's difficult to guess.)

Greg
 
J

Jenkins

Thanks. I only have ftp access to the server, otherwise, I could have used a
cron. Also, if I do it the way I mentioned, is there any way to obtain and
kill the child pid?

doug
 
S

Stan Mooney

hmm

well, unless you get the cooperation of your admins,
maybe you could do something like set cron to wget a
particular html doc which would cause the script to run, doing
this every hour or whatever.

the doc may be in a non-linked-to dir so that its discovery
woudl be unlikely (not that it really matters, i guess).

while it seems there are some other things youd like to do,
perhaps you could build on this basic idea.

im pretty out of it right now, so i hope this is of help - if not, then
have a good laugh :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top