X-Spam-Check-By: sourceware.org Date: Fri, 21 Apr 2006 16:02:06 -0700 From: "Jerry D. Hedden" Subject: RE: How to prevent duplicate cron jobs? To: cygwin AT cygwin DOT com Message-ID: <20060421160206.fb30e530d17747c2b054d625b8945d88.4b678de279.wbe@email.secureserver.net> MIME-Version: 1.0 Content-Type: TEXT/plain; CHARSET=US-ASCII User-Agent: Web-Based Email 4.1.13 X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com > I have a cron job running perl and it is taking a very long time -- > sometimes over 24 hours. > > How can I have cron schedule my job daily, or even hourly, and have > the perl code exit if a previouse instance of the job is still > running? Use Proc::Daemon in conjunction with Proc::PID::File. Both can be found on CPAN. #!/usr/bin/perl use strict; use warnings; use Proc::Daemon; use Proc::PID::File; MAIN: { # Daemonize Proc::Daemon::Init(); # If already running, then exit if (Proc::PID::File->running()) { exit(0); } # Do work .... } exit(0); # EOF -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/