Mary Rose Cook

Using cron with Rails on Slicehost

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.

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

  2. 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.

 

Books I have read recently

Practical Common Lisp, Peter Seibel

DMZ: On The Ground, Brian Wood and Riccardo Burchielli

For Whom The Bell Tolls, Ernest Hemingway

Collective Intelligence, Toby Segaran

The Best of Technology Writing 2007, Steven Levy, editor

Political Philosphy, David Miller

Hackers And Painters, Paul Graham

Violent Cases, Neil Gaiman and Dave McKean

Surely You’re Joking, Mr Feynman!, Richard P. Feynman

 

A beautiful boy

I am totally in love with Spencer Krug. I adore how he gets so angry when he sings.

</embed>
 

Tweviews

Tiny reviews on Twitter.

How artfully can you describe your impression of a song or a movie, a book or an album? There is no space for value judgements, no room for, “this sucks”. Just tell us something interesting. We want to see the inner life of this piece of art. We want you to make us care about it.

  • The Wire Series 4 … A satisfying meal and a great, rippling flood of causation.
  • For Whom The Bell Tolls, Hemingway … Written close to the ground, to the tongue - at the contact points between man and world.

To get these little gems and others like them, follow tweviews on Twitter.

To post a tweview, send a Twitter update like this: ‘@tweviews item, author … review’.

To find out more, check out the tweviews website.

 

The Compiling Defence

Source: xkcd comic 303

In my dynamic, Ruby-infused world, the Compiling Defence is disappointingly impotent.

However, since I began using Capistrano on Joyent shared servers, I have found an even better defence: “Deploying!”

 

EJ

Taken with the iPhone at the weekend.

 

For Whom The Bell Tolls

I saw my old friend, Max, this weekend and he recommended For Whom The Bell Tolls. I bought a copy and started it on the train home from Leeds. I have just got to a very tense scene where Robert is in the guerrillas’ cave and is asserting his authority over the disillusioned Pablo.

Hemingway writes so plainly and everything is so well grounded, literally, in the senses. He gives us a few specific details to convey a meal, or an environment. His rope-soled canvas shoes and his oily wines are impressions that rest upon our tongues and beneath our feet - at our points of contact with the world.

A few years ago, I was killing time at the airport and I read the first few pages of a Tom Clancy novel. Clancy is a writer who, presumably to maximise his output, begins sentences with very little idea of where they are going. So, he spends most of his time writing himself out of linguistic holes. He will go to extraordinary lengths to avoid repetition, referring to the spinning blades of the helicopter to avoid repeating the word rotor. In contrast, if Hemingway has said wine already, he will say it again if it helps make the sentence clearer.

 

C4[1] videos available

The videos from C41, the second iteration of the Mac software development conference, are now online at curator Rentzsch’s website.

Wil Shipley’s talk on hype is particularly good.

 

241

I just cannot stop listening to B. Fleischmann’s Melancholie, an electronica re-interpretation of Schubert piano miniatures. So beautiful and so sad. Danke, Theresa. Get it.

 

243

Heading off to Berlin. A guy with a skateboard has, so far, been with me the whole way. I wonder of he is going too.