.. and don't forget to put out an error message (possibly email it or send
it to a monitoring system) for when the lock file exists. If the previous
run fell over/got killed/machine crashed/etc while running, the lock file
may not have been deleted. You need to pick this up or the job will never
run again. Perhaps your script can be "intelligent" and just delete the lock
file if it is older than a certain time (e.g. created yesterday/over an hour
ago/etc).
:)
John.
-----Original Message-----
From: pmurgatroyd
[mailto:oracledba-ezmlmshield-x61111996.[Email address protected]
Sent: 03 July 2006 06:57
To: LazyDBA Discussion
Subject: RE: Checking if a script is already running ...
A lot of our scripts here will simply create a lock file when they run. The
first thing they do when starting is to check for the lock file, and if it
finds it, the script exits without doing anything. This is mainly used by
our cron jobs so that we prevent multiple instances of the same script
gettig
things tied in a knot.
Cheers,
Paul
>-- Original Message --
>To: "LazyDBA Discussion" <[Email address protected]
>From: "benbart" <oracledba-ezmlmshield-x69180235.[Email address protected]
>Date: Mon, 3 Jul 2006 16:27:29 +1200
>Subject: Checking if a script is already running ...
>
>
>Hi all,
>
>Does anyone have a smarter script to check whether a certain script is
already
>running and if so exit from the script instead of running another instance
>of
>the script?
>
>At the moment, am checking it using ps -ef | grep [scriptname], but found
>out
>that this is not a reliable test as someone could be more'ing or cat'ting
>a
>file and I am mistakenly taking it as the script running ...
>
>Any advise or tips will be very much appreciated ... thanks in advance ...
>
>
>
>
>
>--------
>website: http://www.LazyDBA.com
>Please don't reply to RTFM questions
>Oracle documentation is here: http://tahiti.oracle.com
>To unsubscribe: see http://www.lazydba.com/unsubscribe.html
>To subscribe: see http://www.lazydba.com
>By using this list you agree to these
terms:http://www.lazydba.com/legal.html
--------
website: http://www.LazyDBA.com
Please don't reply to RTFM questions
Oracle documentation is here: http://tahiti.oracle.com
To unsubscribe: see http://www.lazydba.com/unsubscribe.html
To subscribe: see http://www.lazydba.com
By using this list you agree to these
terms:http://www.lazydba.com/legal.html
-----------------------------------------
Information in this email including any attachments may be
privileged, confidential and is intended exclusively for the
addressee. The views expressed may not be official policy, but the
personal views of the originator. If you have received it in error,
please notify the sender by return e-mail and delete it from your
system. You should not reproduce, distribute, store, retransmit,
use or disclose its contents to anyone.
Please note we reserve the right to monitor all e-mail
communication through our internal and external networks.
SKY and the SKY marks are trade marks of British Sky Broadcasting
Group plc and are used under licence. British Sky Broadcasting
Limited (Registration No. 2906991), Sky Interactive Limited
(Registration No. 3554332), Sky-In-Home Service Limited
(Registration No. 2067075) and Sky Subscribers Services Limited
(Registration No. 2340150) are direct or indirect subsidiaries of
British Sky Broadcasting Group plc (Registration No. 2247735). All
of the companies mentioned in this paragraph are incorporated in
England and Wales and share the same registered office at Grant
Way, Isleworth, Middlesex TW7 5QD.
Oracle LazyDBA home page