John Bullhuo
John Bullhuo

Reputation: 71

What's the simplest way to run a cron job on a standalone Ruby gem?

I have a gem that packages one .rb file containing my class and associated methods as well as a corresponding .bin file.

Locally, I can run everything just fine like so:

command_to_bin input_file output_file

I don't want to run this manually every day so I'm considering using cron on a server, but I'm a little unsure how to proceed.

Do I throw everything into a directory (.gem file, input file, output file) and just point the above cron command at the directory?

I've looked at this and sort of understand what's going on. I guess what confuses me the most is that when I look at all the web hosting providers, they mention domains and applications, but I just want to know how to have the standalone script run by itself without it being built into a web application or associated with a domain.

Upvotes: 0

Views: 487

Answers (2)

Alex Levine
Alex Levine

Reputation: 1587

You don't need to install Rails. After you wheneverize . the directory and set the schedule in your schedule.rb file, you need to run whenever --update-crontab to set everything to the system. Otherwise your cron jobs never get converted to Unix Cron

Upvotes: 0

Benjamin Tan Wei Hao
Benjamin Tan Wei Hao

Reputation: 9691

Check out the whenever gem. It's a wonderful gem to abstract all the nastiness of cron. Just include the command as you have written above and it should be fine.

Upvotes: 3

Related Questions