Forum: Ruby script gets executed multiple times by cron

Posted by Panagiotis Atmatzidis (Guest)
on 2013-01-22 01:58
(Received via mailing list)
Hello,

I'm running this script https://gist.github.com/4591053 on a freebsd 
(default) crontab server using RVM + cron configuration. I don't know 
for which reason
but the program gets executed multiple times. I just want to execute the 
program one time every day at 4 a.m. (local time).

Here's my freebsd user crontab:
---
[atma@comodino ~/Code/rankclient]$ crontab -l
# atma's crontab!

# Shell variables for crontab
SHELL=/usr/local/bin/bash
PATH=/home/atma/.rvm/gems/ruby-1.9.3-p194/bin:/home/atma/.rvm/gems/ruby-1.9.3-p194@global/bin:/home/atma/.rvm/rubies/ruby-1.9.3-p194/bin:/home/atma/.rvm/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/home/atma/bin:/home/atma/.rvm/bin
RUBYLIB=/home/atma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/
GEM_HOME=/home/atma/.rvm/gems/ruby-1.9.3-p194
GEM_PATH=/home/atma/.rvm/gems/ruby-1.9.3-p194:/home/atma/.rvm/gems/ruby-1.9.3-p194@global

* 4 * * * /home/atma/Code/rankclient/rankclient.rb
----

When I'm running this script manually everything works fine. But when 
I'm running this script using crontab, well it gets execute 10+ times in 
a row.

Any idea why this happens?


Panagiotis (atmosx) Atmatzidis

email:  atma@convalesco.org
URL:  http://www.convalesco.org
GnuPG ID: 0xE736C6A0
gpg --keyserver x-hkp://pgp.mit.edu --recv-keys 0xE736C6A0
Posted by Matt Lawrence (Guest)
on 2013-01-22 02:32
(Received via mailing list)
On Tue, 22 Jan 2013, Panagiotis Atmatzidis wrote:

> # Shell variables for crontab
> SHELL=/usr/local/bin/bash
> 
PATH=/home/atma/.rvm/gems/ruby-1.9.3-p194/bin:/home/atma/.rvm/gems/ruby-1.9.3-p194@global/bin:/home/atma/.rvm/rubies/ruby-1.9.3-p194/bin:/home/atma/.rvm/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/home/atma/bin:/home/atma/.rvm/bin
> RUBYLIB=/home/atma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/
> GEM_HOME=/home/atma/.rvm/gems/ruby-1.9.3-p194
> 
GEM_PATH=/home/atma/.rvm/gems/ruby-1.9.3-p194:/home/atma/.rvm/gems/ruby-1.9.3-p194@global
>
> * 4 * * * /home/atma/Code/rankclient/rankclient.rb

Try putting something in the minutes field.

-- Matt
It's not what I know that counts.
It's what I can remember in time to use.
Posted by tamouse mailing lists (Guest)
on 2013-01-22 15:37
(Received via mailing list)
On Mon, Jan 21, 2013 at 6:55 PM, Panagiotis Atmatzidis
<atma@convalesco.org> wrote:
> * 4 * * * /home/atma/Code/rankclient/rankclient.rb

This is telling cron to run the job every minute in the 4th hour. See
man 5 crontab.
Posted by Panagiotis Atmatzidis (Guest)
on 2013-01-22 15:54
(Received via mailing list)
Hello,

I've read two quick guides, I thought I figured but apparently I got it 
all wrong! Makes perfectly sense.

Thanks for the explanation,

Best Regards


Panagiotis (atmosx) Atmatzidis

email:  atma@convalesco.org
URL:  http://www.convalesco.org
GnuPG ID: 0xE736C6A0
gpg --keyserver x-hkp://pgp.mit.edu --recv-keys 0xE736C6A0
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
No account? Register here.