Professional Web Applications Themes

Check if another script running - PERL Beginners

Hello, I need to setup a cronjob to run a script every 2hrs, but if another particular script(executed via a standard web form), on the same machine, is being executed, I want the cron script "wait" or "sleep();" till the other script is finished. Is this possible to do and how is the best way to accomplish this task. :) TIA -- Mike<mickalo>Blezien =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Thunder Rain Internet Publishing Providing Internet Solutions that work! http://www.thunder-rain.com =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=...

  1. #1

    Default Check if another script running

    Hello,

    I need to setup a cronjob to run a script every 2hrs, but if another particular
    script(executed via a standard web form), on the same machine, is being
    executed, I want the cron script "wait" or "sleep();" till the other script is
    finished.

    Is this possible to do and how is the best way to accomplish this task. :)

    TIA
    --
    Mike<mickalo>Blezien
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    Thunder Rain Internet Publishing
    Providing Internet Solutions that work!
    http://www.thunder-rain.com
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

    Mike Guest

  2. #2

    Default Check if another script running

    Hello,

    I need to setup a cronjob to run a script every 2hrs, but if another particular
    script(executed via a standard web form), on the same machine, is being
    executed, I want the cron script "wait" or "sleep();" till the other script is
    finished.

    Is this possible to do and how is the best way to accomplish this task. :)

    TIA
    --
    Mike<mickalo>Blezien
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    Thunder Rain Internet Publishing
    Providing Internet Solutions that work!
    http://www.thunder-rain.com
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


    Mike Guest

  3. #3

    Default Check if another script running

    Hello,

    I need to setup a cronjob to run a script every 2hrs, but if another particular
    script(executed via a standard web form), on the same machine, is being
    executed, I want the cron script "wait" or "sleep();" till the other script is
    finished.

    Is this possible to do and how is the best way to accomplish this task. :)

    TIA
    --
    Mike<mickalo>Blezien
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    Thunder Rain Internet Publishing
    Providing Internet Solutions that work!
    http://www.thunder-rain.com
    Quality Web Hosting
    http://www.justlightening.net
    MSN: com
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

    Mike Guest

  4. #4

    Default Re: Check if another script running

    On 4/1/2004 3:46 PM, Mike Blezien wrote:
     

    If you are able to modify both scripts, the traditional solution would
    be to have the cgi script create a lock file on startup, removing it
    when exiting. Then your other script can check for the presence of the
    lock file, if it exists, wait.

    Regards,
    Randy.


    Randy Guest

  5. #5

    Default RE: Check if another script running

    I think your question is more related to unix than perl.
    Try something like this in shell script :
    program=$0
    while ps -ef | grep $0 | grep -v grep | grep $$
    do
    sleep 10
    done

    or in perl

    $program=$0;
    while ( `ps -ef | grep $0 | grep -v grep | grep $$` ) {
    sleep 10 ;
    }

    ** I did not check the stuff... ***

    Jay

    -----Original Message-----
    From: Mike Blezien [mailto:net]
    Sent: Thursday, April 01, 2004 3:47 PM
    To: Perl List
    Subject: Check if another script running


    Hello,

    I need to setup a cronjob to run a script every 2hrs, but if another particular
    script(executed via a standard web form), on the same machine, is being
    executed, I want the cron script "wait" or "sleep();" till the other script is
    finished.

    Is this possible to do and how is the best way to accomplish this task. :)

    TIA
    --
    Mike<mickalo>Blezien
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    Thunder Rain Internet Publishing
    Providing Internet Solutions that work!
    http://www.thunder-rain.com
    Quality Web Hosting
    http://www.justlightening.net
    MSN: com
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


    --
    To unsubscribe, e-mail: org
    For additional commands, e-mail: org
    <http://learn.perl.org/> <http://learn.perl.org/first-response>


    Jayakumar Guest

  6. #6

    Default Re: Check if another script running

    Hi Randy,

    that was my original plan, but I though there maybe a better way others may use
    or suggest :)

    Appreciate the feedback,

    Mike

    Randy W. Sims wrote: 
    >
    >
    > If you are able to modify both scripts, the traditional solution would
    > be to have the cgi script create a lock file on startup, removing it
    > when exiting. Then your other script can check for the presence of the
    > lock file, if it exists, wait.
    >
    > Regards,
    > Randy.[/ref]

    Mike Guest

  7. #7

    Default RE: Check if another script running

    sorry.. I missed one thing..
    This is the right condition line:
    ps -ef | grep $0 | grep -v $$ | grep -v grep | grep $0

    -----Original Message-----
    From: Jayakumar Rajagopal
    Sent: Thursday, April 01, 2004 5:30 PM
    To: net; Perl List
    Subject: RE: Check if another script running


    I think your question is more related to unix than perl.
    Try something like this in shell script :
    program=$0
    while ps -ef | grep $0 | grep -v grep | grep $$
    do
    sleep 10
    done

    or in perl

    $program=$0;
    while ( `ps -ef | grep $0 | grep -v grep | grep $$` ) {
    sleep 10 ;
    }

    ** I did not check the stuff... ***

    Jay

    -----Original Message-----
    From: Mike Blezien [mailto:net]
    Sent: Thursday, April 01, 2004 3:47 PM
    To: Perl List
    Subject: Check if another script running


    Hello,

    I need to setup a cronjob to run a script every 2hrs, but if another particular
    script(executed via a standard web form), on the same machine, is being
    executed, I want the cron script "wait" or "sleep();" till the other script is
    finished.

    Is this possible to do and how is the best way to accomplish this task. :)

    TIA
    --
    Mike<mickalo>Blezien
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    Thunder Rain Internet Publishing
    Providing Internet Solutions that work!
    http://www.thunder-rain.com
    Quality Web Hosting
    http://www.justlightening.net
    MSN: com
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


    --
    To unsubscribe, e-mail: org
    For additional commands, e-mail: org
    <http://learn.perl.org/> <http://learn.perl.org/first-response>



    --
    To unsubscribe, e-mail: org
    For additional commands, e-mail: org
    <http://learn.perl.org/> <http://learn.perl.org/first-response>


    Jayakumar Guest

  8. #8

    Default Re: Check if another script running

    On Thu, 01 Apr 2004 16:34:11 -0600
    Mike Blezien <net> wrote:
     

    If you are running this on a Unix/Linux system check out perldoc -f
    flock. It enables advisory file locking. It avoids the complexity of
    doing file locking by creating sentinel files using the standard Unix
    atomic open semantics. There are some serious race condition problems
    with that approach.

    The information in the perl manual for flock contains an example mailbox
    locking routine which explains how to use flock to grant exclusive
    access to a file.

    --
    Smoot Carl-Mitchell
    Systems/Network Architect
    email: com
    cell: +1 602 421 9005
    home: +1 480 922 7313
    Smoot Guest

  9. #9

    Default RE: Check if another script running



    -----Original Message-----
    From: Mike Blezien [mailto:net]
    Sent: Thursday, April 01, 2004 3:16 PM
    To: Perl List
    Subject: Check if another script running


    Hello,

    I need to setup a cronjob to run a script every 2hrs, but if another particular
    script(executed via a standard web form), on the same machine, is being
    executed, I want the cron script "wait" or "sleep();" till the other script is
    finished.

    Is this possible to do and how is the best way to accomplish this task. :)

    TIA
    --
    Mike<mickalo>Blezien

    Mike,
    Are you sending this mail through a cronjob? You have been provided 3 different answers, but still you are sending the same question for 3rd or 4th time?
    Jay
    Jayakumar Guest

  10. #10

    Default Re: Check if another script running

    My appologize for the multiple emails... something went hay-wire with our mail
    server yesterday.. sending out multiple emails.

    this question has been resolved,.. thanks to the list for the help :)

    Mike

    Jayakumar Rajagopal wrote: 

    Mike Guest

Similar Threads

  1. Ways to check the status of a long-running transaction
    By Jim C. Nasby in forum PostgreSQL / PGSQL
    Replies: 1
    Last Post: January 20th, 04:57 AM
  2. Running Preflight Check Programmatically From VB
    By Phil_Galey@adobeforums.com in forum Adobe Acrobat Windows
    Replies: 0
    Last Post: May 18th, 05:18 PM
  3. check a running process, impersonate
    By bob Sterrett in forum ASP.NET Security
    Replies: 0
    Last Post: March 6th, 07:13 PM
  4. Please check this script. (small script to check)
    By rabbott in forum Macromedia Flash Actionscript
    Replies: 0
    Last Post: February 11th, 04:28 PM
  5. Replies: 4
    Last Post: October 22nd, 01:18 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139