Ruby have one very powerful tool called whenever

You can install it with

gem install whenever

After installation, you need to create config/schedule.rb file, where you can put your crontab jobs.

Schedule.rb syntax is pretty straightforward, for example:


every :day, :at => '12:30am' do
command '/home/ec2-user/script'
end

The schedule.rb from above will automatically create cronjob which will execute every day at 12:30 after midnight.

All you need to do is call command:

whenever --update

... and it will setup cronjob for you automatically!