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
on 2013-01-24 12:33
on 2013-01-24 13:34
On Thu, Jan 24, 2013 at 12:32 PM, Dwayne Henderson <its.code.in.here@gmail.com> wrote: > > */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 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. Kind regards robert
on 2013-01-24 13:40
On Thu, Jan 24, 2013 at 1:33 PM, Robert Klemme <shortcutter@googlemail.com>wrote: > 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
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.