Reputation: 74
I am pre-storing records in a table A
and I want to transfer these records from table A
to table B
automatically at a specific time, lets say on every evening at 08:00 PM.
Any ideas on how to solve this little problem?
Upvotes: 0
Views: 189
Reputation: 5112
You can use whenever gem to run cron jobs ...for example job that runs every 5 mins
in schedule.rb
every 5.minutes do
rake "transfer_data:send_data"
end
lib/tasks/send_data.rake
#!/usr/bin/env ruby
namespace :transfer_data do
desc "Rake task to transfer data
task :send_data => :environment do
## code to transfer data from one table to other table
end
end
Execute the task using bundle exec rake transfer_data:send_data
Upvotes: 0
Reputation: 3311
You could create rake task to implement your job, and then schedule it with cron, default *nix time manager. Its syntax is difficult to remember, so I prefer to use Ruby wrapper around it, gem whenever.
Upvotes: 3