0

Ruby 1.8.7 I have a post.rake and how to run rake task every day?

  1. solution add a script in cron:

    0 0 * * * /path/script.sh

script.sh:

#!/bin/bash
source /home/user/.bashrc
cd /path/to/project
export RAILS_ENV=production
bundle exec rake post:crontask -s

May have other solutions?

Nar
  • 540
  • 1
  • 9
  • 22

2 Answers2

1

That's not a bad approach. There are some popular Ruby gems that make things easier. whenever and rufus-scheduler are both popular. They also work with Ruby 1.8.7, which isn't likely to be true of most alternatives.

Jim Stewart
  • 16,964
  • 5
  • 69
  • 89
0

What about

0 0 * * * cd /path/to/project && env RAILS_ENV=production bundle exec rake post:crontask -s
Sergio Tulentsev
  • 226,338
  • 43
  • 373
  • 367
Stuart M
  • 11,458
  • 6
  • 45
  • 59