maryrosecook.com
                        a diary and a mask
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
Using cron with Rails on Slicehost
cron, rails, slicehost, help

I need to run a model method on my Slicehost production app every hour. I tried rake+cron, cronedit and a number of nut.crack(sledgehammer) queueing server solutions. Some didn’t work and the rest were unreliable. Therefore, for all you Ruby On Rails On Slicehost people, here is my approach. Treasure it.

1. ssh into your Slicehost account.

2. Switch to your user directory: cd ~/

3. Make a new directory: mkdir cronlogs

4. Make a new cron log file: nano notifications.log

5. Add a space to the file and then save it.

6. The crontab is a text file that holds all your scheduled cron jobs. Edit it: crontab -e

7. We are going to enter a line into this file. It will have the following structure: [timings] [switch to your app directory] && [path to ruby] script/runner -e [environment] [method to run] > [path to cron log]

8. Here is what I entered into my crontab. When you write your own version, make sure that the paths reflect where you have stored ruby and your app, and that you fill in the blank for your app name and set your own timings. 1 1 * * * cd /home/admin/public_html/[your app name]/current && /usr/local/bin/ruby script/runner -e production 'Match.generate_and_save_matches' > ~/cronlogs/notifications.log

8a. It is a good idea to test the command you enter (minus the scheduling information) in your command line. If it doesn’t work there, it won’t work when run by cron, either.

9. If you try and save your crontab and it says you have errors, make sure the whole thing is on one line.

10. If your model method runs OK, you will probably get no feedback. However, if there was an error, you should either get some mail or something should get written to the cron log you created.

The tweet I sent once I got this working. 08.05.08  λ 


Mary is involved with queer, anti-capitalist and DIY stuff; Mary is a band and a programmer; Mary lives in London.
What I'm working on
the perceptron. Astute music recommendations.
Audiographical. An mp3 blog.
We're Not The Cool Kids. My band.

Twitter: Thinking of registering javaisfordickheads.com

Tweviews - tiny reviews on Twitter

Copilot.com Awesome for helping people with tech support (free on weekends!)

A Silver Mt Zion, Horses In The Sky ... A fragile man's fragile voice is shored-up with strings and bows.

Happening, M Night Shyamalan ... Overheard after the film: "They missed out a whole chapter man". Everyone was scratching their heads

Harold and Kumar 2 ... Crasser than the first one. Gross, but had a few moments.

Heaven, Tom Tykwer ... Congenitally doomed man and woman bear hope enough to find a beautiful end.

 Subscribe to this blog (RSS 2)
Just frail black on spare white, like your favourite song is just a string of bits.