How to use a Rails cron job to run a program in Java?

Asked

Viewed 220 times

0

Is it possible to use a cron job in Rails to execute a command that runs a class in Java? If so, how?

  • 1

    you talk about running a . jar already compiled in java?

2 answers

0

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, as long as it is "chargeable" per command line.

0


You must use the call Gem Whenever There will keep your crontab in ruby code, the idea is to write all the rules and together with the deploy do the crontab update.

1st In your Gemfile enter

gem 'whenever', :require => false

2º Create the file Schedule.Rb

wheneverize .

3º In the file Schedule.Rb

#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

4º On the server run the command to update the crontab table, if you are using Pristan, put in your deploy stream

whenever --update-crontab

Browser other questions tagged

You are not signed in. Login or sign up in order to post.