# Port listening, cron jobs and loading rails environment

**URL:** <https://www.ruby-forum.com/t/port-listening-cron-jobs-and-loading-rails-environment/129889>\
**Category:** Rails\
**Created:** [February 22, 2008, 12:43pm UTC](https://www.ruby-forum.com/t/port-listening-cron-jobs-and-loading-rails-environment/129889 "2008-02-22T12:43:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ratcheer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/aca169/32.png) [@ratcheer](https://www.ruby-forum.com/u/ratcheer)\
**Post date:** [February 22, 2008, 12:43pm UTC](https://www.ruby-forum.com/t/port-listening-cron-jobs-and-loading-rails-environment/129889/1 "2008-02-22T12:43:13Z")

</div>

Hi,  
As part of a web application that I am writing I need to have something  
listening for any packets that are received on a particular port and  
then process the packets using some of my Rails models, hence I start  
the script via the ./script/runner command.  
This script always needs to be running, if it exits for any reason, I  
need it to start up again very quickly. Hence, I was considering  
writing a simple script that gets called every minute via a cron job.  
This script will check to see if anything is currently listening on the  
particular port, and if not, call the script/runner command to start the  
listener script again.  
Does this seem like a reasonable way of making sure my listener script  
is always running or is there another/better way?  
Thanks  
T

---

<div class="post-metadata">

**Author:** ![ratcheer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/aca169/32.png) [@ratcheer](https://www.ruby-forum.com/u/ratcheer)\
**Post date:** [February 22, 2008, 2:56pm UTC](https://www.ruby-forum.com/t/port-listening-cron-jobs-and-loading-rails-environment/129889/2 "2008-02-22T14:56:33Z")

</div>

monit is right up to your needs
