how to make the whenever gem to run a cron job

13 views
Skip to first unread message

dv dhanadan

unread,
Jan 6, 2012, 11:46:26 PM1/6/12
to rubyonra...@googlegroups.com
how to make the whenever gem to run a cron job?
I have installed the whenever gem into my rails project
successfully,could any one tell me on how i can get this gem run a rake
task for me...

--
Posted via http://www.ruby-forum.com/.

Colin Law

unread,
Jan 7, 2012, 3:45:59 AM1/7/12
to rubyonra...@googlegroups.com
On 7 January 2012 04:46, dv dhanadan <li...@ruby-forum.com> wrote:
> how to make the whenever gem to run a cron job?
> I have installed the whenever gem into my rails project
> successfully,could any one tell me on how i can get this gem run a rake
> task for me...

If you are using cron then you do not need to use whenever. Simple
run the rake task from cron.

Colin

Alex Mercer

unread,
Jan 7, 2012, 5:50:30 AM1/7/12
to Ruby on Rails: Talk
Whenever just helps to use cron with simple ruby syntax.
To make it run cronjobs. You need to:
1. Exec in your project folder:
wheneverize .
This will create config/schedule.rb file.

2. There type some action needed to be done with cron:
every 3.hours do
rake "my:rake:task"
end

3. Save it and execute that
whenever --update-crontab
This will update crontab file.
You can ensure that crontab is written by
crontab -l

4. And final point restart cron
sudo services cron restart

Enjoy =)

Colin Law

unread,
Jan 7, 2012, 6:21:03 AM1/7/12
to rubyonra...@googlegroups.com
On 7 January 2012 10:50, Alex Mercer <alexey....@gmail.com> wrote:
> Whenever just helps to use cron with simple ruby syntax.

If I had looked up whenever before replying then my post might have
been more helpful :(

Colin

Dharmdip Rathod

unread,
Jan 7, 2012, 7:55:21 AM1/7/12
to rubyonra...@googlegroups.com
whenever --update-crontab -set='environment=development'

dv abhi

unread,
Jan 10, 2012, 7:58:46 AM1/10/12
to rubyonra...@googlegroups.com
"And final point restart cron
sudo services cron restart"

I am using Ubuntu 10.04,i tried running this code sudo /etc/init.d to
restart the cron,but did not work,do you have any fixes for that

Alex Mercer

unread,
Jan 10, 2012, 3:59:22 PM1/10/12
to Ruby on Rails: Talk
dv abhi,
Can you provide more info?
Have you tried to run `sudo services cron restart` and what output it
gives?
Reply all
Reply to author
Forward
0 new messages