# Port listening, cron jobs and loading rails environment

**URL:** <https://discuss.rubyonrails.org/t/port-listening-cron-jobs-and-loading-rails-environment/25312>\
**Category:** rubyonrails-talk\
**Created:** [February 22, 2008, 11:43am UTC](https://discuss.rubyonrails.org/t/port-listening-cron-jobs-and-loading-rails-environment/25312 "2008-02-22T11:43:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [February 22, 2008, 11:43am UTC](https://discuss.rubyonrails.org/t/port-listening-cron-jobs-and-loading-rails-environment/25312/1 "2008-02-22T11: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:** ![lq1](https://avatars.discourse-cdn.com/v4/letter/l/ecc23a/32.png) [@lq1](https://discuss.rubyonrails.org/u/lq1)\
**Post date:** [February 22, 2008, 1:55pm UTC](https://discuss.rubyonrails.org/t/port-listening-cron-jobs-and-loading-rails-environment/25312/2 "2008-02-22T13:55:53Z")

</div>

monit is right up to your needs
