Is it possible to use a cron job in Rails to execute a command that executes a class in Java? If so how?
Is it possible to use a cron job in Rails to execute a command that executes a class in Java? If so how?
You should use gem called whenever and it will keep your crontab in ruby code, the idea is to write all the rules together with deploy updating the crontab.
1st In your GemFile insert
gem 'whenever', :require => false
Create the schedule.rb
wheneverize .
3rd In the schedule.rb file
#aqui você pode definir a frequência que o código vai ser executado, ler readme do github
every 1.day, :at => '4:30 am' do
command "java {chamada do programa java}"
end
On the server run the command to update the crontab table, if you are using capristano, put it in your deploy stream
whenever --update-crontab
Rails does not have cron job, this is the task of the operating system. And yes, you can use cron to call a program in java, if it is callable by the command line.