Reputation: 95
I am just trying to create a record every 5 minutes using whenever gem
but it doesn't create anything on the production.
config/schedule.rb
every 5.minutes do
runner "Post.new_post"
end
lib/tasks/post.rb
class Post
def new_post
Post.create(title: "cron testing")
end
end
and I ran whenever
command then pushed to the live server but It doesn't create any records on the production.
Which steps did I miss?
Upvotes: 1
Views: 732
Reputation: 691
I'm assuming that you're using rails, so — files placed in lib/tasks are loaded as custom rake tasks by default, you can check it here.
Brief instruction:
rails generate task posts create_post
lib/tasks/posts.rake
config/schedule.rb
from
runner "Post.new_post"
to rake 'posts:create_post'
whenever --update-crontab
somehow on the server ;)Upvotes: 1