Simulating script/console for backend process

Go to your RAILS_ROOT folder and then:

script/runner "here goes the name of your script" -e production

Read the help:

script/runner -h
Usage: script/runner [options] ('Some.ruby(code)' or a filename)

    -e, --environment=name Specifies the environment for the
runner to operate under (test/development/production).
                                     Default: development

    -h, --help Show this help message.

You can also use runner as a shebang line for your scripts like this:

Generally, you want to put this sort of thing in a rake task (instead
of a script) and then your cron is just
cd /application_rails_directory; rake do_my_thing --RAILS_ENV=production