How to crontab screen with script inside and a "don't run it if it's already running" check?
I run this Ruby script 24/7 (records data from this live stream). It runs inside a screen though, so it's easy to check in on it every once in a while. But how do I crontab the screen with the script inside it? It has to be with a "don't run it if it's already running" check. So far I have this (untested) - what y'all think? */10 * * * * lockf -t 0 /home/anonymous/.myscript.lock /usr/local/bin/screen -dm /home/anonymous/.rvm/rubies/ruby-1.9.3-p0/bin/ruby /home/anonymous/myscript.rb --Dwayne ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
Re: How to crontab screen with script inside and a "don't run it if it's already running" check?
Hello Jens! Nice. But what to do if the machine reboots or whatever. Would you crontab your new Irssi alias? --Dwayne On Fri, Jun 1, 2012 at 9:39 PM, Jens Jahnke wrote: > Hi, > > On Fri, 1 Jun 2012 20:55:00 +0200 > Dwayne Henderson wrote: > > DH> I run this Ruby script 24/7 (records data from this live stream). > DH> It runs inside a screen though, so it's easy to check in on it > DH> every once in a while. > DH> > DH> But how do I crontab the screen with the script inside it? It has > DH> to be with a "don't run it if it's already running" check. > DH> [...] > > maybe you should create a shell alias. I do the following for my irssi > session: > > # Start irssi within screen or switch to it if it is already running. > alias irssi='if pgrep -u $USER irssi;then screen -U -x irssi;else screen > -S irssi irssi;fi' > > Regards, > > Jens > > -- > 01. Brachet 2012, 21:37 > Homepage : http://www.jan0sch.de > > It is a sobering thought that when Mozart was > my age, he had been dead for 2 years. >-- Tom Lehrer > ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
Re: How to crontab screen with script inside and a "don't run it if it's already running" check?
Any comments on this though? */10 * * * * lockf -t 0 /home/anonymous/.myscript.lock /usr/local/bin/screen -dm /home/anonymous/.rvm/rubies/ ruby-1.9.3-p0/bin/ruby /home/anonymous/myscript.rb Thanks for the help! --Dwayne On Sat, Jun 2, 2012 at 12:57 PM, Jens Jahnke wrote: > Hello Dwayne, > > On Sat, 2 Jun 2012 10:59:09 +0200 > Dwayne Henderson wrote: > > DH> Nice. But what to do if the machine reboots or whatever. Would you > DH> crontab your new Irssi alias? > > I'm not sure. On my remote box I usually start irssi by hand because it > only ceases if the machine is rebooted. ;-) > > The current alias itself would probably cause problems in > a crontab. But you could maybe wrap it into a modified if that only > calls the alias if the pgrep command returns an empty result. > > Regards, > > Jens > > -- > 02. Brachet 2012, 12:54 > Homepage : http://www.jan0sch.de > > Optimist, n.: >A bagpiper with a beeper. > ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
Crontabbing a Ruby script inside a screen
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 Thank you! --Dwayne ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
Re: Crontabbing a Ruby script inside a screen
On Thu, Jan 24, 2013 at 1:33 PM, Robert Klemme wrote: > > I am not 100% sure what you want to achieve. But it seems to me that > it would be easier to wrap your Ruby script in something else that > restarts the script if it crashes. Like > > #!/usr/bin/dash > > # no cores > ulimit -c 0 > > while :; do > /home/anonymous/.rvm/rubies/ruby-1.9.3-p0/bin/ruby > /home/anonymous/myscript.rb > done > > And have screen start this script. > My God, Robert, this is brilliant :D Thanks a bunch man. Nice blog too! --Dwayne > > Kind regards > > robert > > -- > remember.guy do |as, often| as.you_can - without end > http://blog.rubybestpractices.com/ > > ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"