iCyborg
iCyborg

Reputation: 4728

How to run following code in rails using Cron ?

I was looking at railscast http://railscasts.com/episodes/168-feed-parsing?view=asciicast where the author is pulling the rss feed in the database through rails console by typing

FeedEntry.update_from_feed("http://asciicasts.com/episodes.xml")

now this is working fine for the first time but how to do this every 24 hours ? How to use cron here ?

Thanks

Upvotes: 1

Views: 49

Answers (2)

Hauleth
Hauleth

Reputation: 23556

You can use whenever gem as @dimuch said, but also you can run cron with this command:

$ rails runner 'FeedEntry.update_from_feed("http://asciicasts.com/episodes.xml")'

Upvotes: 1

dimuch
dimuch

Reputation: 12818

Try to use whenever gem to simplify the task.

Upvotes: 1

Related Questions