From owner-freebsd-questions@FreeBSD.ORG Thu Jan 24 17:04:46 2013 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id D0E7ECD for ; Thu, 24 Jan 2013 17:04:46 +0000 (UTC) (envelope-from c.kworr@gmail.com) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com [209.85.217.178]) by mx1.freebsd.org (Postfix) with ESMTP id 5EE587B4 for ; Thu, 24 Jan 2013 17:04:45 +0000 (UTC) Received: by mail-lb0-f178.google.com with SMTP id n1so5173874lba.37 for ; Thu, 24 Jan 2013 09:04:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=ohAqZkgcnQodTxZyK89cilu0mVVsnqwvrswhR5z4lU0=; b=cz7owFR3tYwrR7ONWlFptrpYh4xzfJEuxQqFooFDWVOeFMpYO2mifHh26+3vNZMEqY Wt1ShMtjN403d7JzDAZiKnE/pa7UyuwI9ySQSUkcpoxkfH27v+LoN2thQLakSIE9awzV HqXdYOVcUUsCQrRuH8Ux0euRHIawgjP3R8zfi3BUR3eYzQt011WcNIdVsgdFYs2ZVlqD 7zHZEr0sfINkI/Ke+OAfgoXF3bxKtOJnEiCFXZmX8UJ1zwaKMxuFRqSR/yCXhN7o5O0d lpnlPFevVPuP4GtXj3KdLsKuVX0MWNEEY+RnflvDSjDpjeazfQKLK/DGqGTHou5CWmub f+XQ== X-Received: by 10.112.54.1 with SMTP id f1mr1082915lbp.85.1359047085137; Thu, 24 Jan 2013 09:04:45 -0800 (PST) Received: from [192.168.1.125] (mau.donbass.com. [92.242.127.250]) by mx.google.com with ESMTPS id b3sm9987157lbl.0.2013.01.24.09.04.42 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 24 Jan 2013 09:04:43 -0800 (PST) Message-ID: <5101699E.1050001@gmail.com> Date: Thu, 24 Jan 2013 19:04:30 +0200 From: Volodymyr Kostyrko User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:18.0) Gecko/20100101 Firefox/18.0 SeaMonkey/2.15 MIME-Version: 1.0 To: Dwayne Henderson Subject: Re: Crontabbing a Ruby script inside a screen References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: ruby-talk@ruby-lang.org, questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jan 2013 17:04:46 -0000 24.01.2013 13:27, Dwayne Henderson: > Hi, I run this Ruby + Sequel script inside a screen that records data from > this live stream 24/7. But it tends to core dump every once in a while, and > since I run it in a screen (so it's easy to check in on), I can't really > scroll up to catch the error whenever it happens. > > So how do I crontab the screen with the Ruby script inside it? Has to be > with a "don't run it if it's already running" check to avoid fatal > consequences. So far I have: > > $ crontab -e > > */10 * * * * lockf -t 0 /home/anonymous/.myscript.rb.lock > /usr/local/bin/screen -d -m -S myscript > /home/anonymous/.rvm/rubies/ruby-1.9.3-p0/bin/ruby > /home/anonymous/myscript.rb Another suggestion would be using daemon(8) with -r option. -- Sphinx of black quartz, judge my vow.