start background process on host server

Discussion in 'Perl' started by Jenkins, Aug 30, 2003.

  1. Jenkins

    Jenkins Guest

    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
    Jenkins, Aug 30, 2003
    #1
    1. Advertising

  2. Jenkins

    Ga Mu Guest

    Jenkins wrote:

    > 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
    Ga Mu, Aug 30, 2003
    #2
    1. Advertising

  3. Jenkins

    Jenkins Guest

    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

    "Ga Mu" <> wrote in message
    news:M854b.307346$Ho3.43699@sccrnsc03...
    > Jenkins wrote:
    >
    > > 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
    >
    Jenkins, Aug 30, 2003
    #3
  4. Jenkins

    Stan Mooney Guest

    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 :)
    Jenkins wrote:
    >
    > 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
    >
    > "Ga Mu" <> wrote in message
    > news:M854b.307346$Ho3.43699@sccrnsc03...
    > > Jenkins wrote:
    > >
    > > > 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
    > >
    Stan Mooney, Aug 31, 2003
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lucas Tam
    Replies:
    0
    Views:
    497
    Lucas Tam
    Jun 17, 2005
  2. zxo102
    Replies:
    5
    Views:
    379
    zxo102
    Aug 15, 2006
  3. Rex Gustavus Adolphus
    Replies:
    5
    Views:
    141
    Rex Gustavus Adolphus
    Jul 4, 2003
  4. Replies:
    14
    Views:
    245
    Martijn Lievaart
    Aug 15, 2009
  5. PerlFAQ Server
    Replies:
    0
    Views:
    180
    PerlFAQ Server
    Feb 23, 2011
Loading...

Share This Page