WTF does that cron do?
I’ll be the first to admit that I’m not a great system administrator. I was a windows guy for so long, so my only exposure to linux was haggling with shared hosting accounts to run my stupid php apps. While my linux/administration skills have grown by leaps and bounds in the last few years, I still get caught up on something as simple as cron jobs. The syntax is very terse, and probably easy to parse for computers. For the rest of us… Well, what the hell does this mean?
*/6 * * * * rake ts:index:delta

According to my new project, CronWTF, that “runs rake ts:index:delta at minutes :00, :06, :12, :18, :24, :30, :36, :42, :48, :54, every hour.”
Okay, to be honest, it’s not that hard to read. Most of the time my jobs run multiple times a day, so I’m only dealing with the first 2 fields (minutes and hours). The real reason I wrote this was for punishment for royally botching up the cron job for the Calendar About Nothing.
I wanted to run the update task every four hours:
* */4 * * * rake seinfeld:update
Then, my server would periodically run out of memory and my host would have to reboot it. I happened to be on the server during one of these ruby storms and noticed a bunch of rake processes piling up. Then I parsed the crontab that I had written: Runs rake seinfeld:update every minute, on hours 0, 4, 8, 12, 16, 20, every day.
Shit! My intensive job scanning 400 github feeds was running 60 times every 4 hours. So, the seeds of CronWTF were planted. I wanted it browser based, so the library is pure javascript with no knowledge of browsers, frameworks, etc. My next step is to make this accessible from the command line through spidermonkey. I could even make it available to ruby apps through the ruby/spidermonkey bridge. I don’t know how it’d be useful, but who cares?
Comments
Comments are closed.

by grosser on 15 Mar 12:56
That is exactly why i do not use crontab for this.
We run rake night every night, which then determines which tasks to run, and the counterpart would be rake frequent, which is run every 15minutes and would do whatever you want.
Imo this is far more secure then hackish cron code and is easier to be updated by non-administrators / does not need to automatically update a crontab file etc etc…
Additionally execution can be logged easily and any exception can be send to exception collector service.
my blog post with code example
by rick on 15 Mar 13:50
Sure, that’s a great tactic. I’m doing the same thing on the Calendar About Nothing actually. But you still need something to call that rake task periodically. And as I stated above, I still managed to fuck that crontab up :) Your example also assumes that the only thing important on my servers is a single rails app.
By the way, you could condense your single crontab to
0 0 */6 * * ...my rake task, since it’s in a private heroku branch:
by Nathan Esquenazi on 15 Mar 14:43
This is a great idea. I have always had an issue with crontab. Not because it is that hard to read (although it can be) but because it is a separate file outside of my application that has to be managed seperately.
I am sure you guys are aware of this plugin:
http://github.com/javan/whenever/tree/master
It is pretty awesome though. I am using it on my current project and it makes life a lot easier.
by Adam Meehan on 15 Mar 17:55
I sympathise with the occasional stuff up with cron. You can go a while without using it and then forget some aspect that mucks up you timing which can have dire effects.
Thats why I created Cronos
Its cron DSL to make it as English as possible to define and interval for cron. Its the compliment of CronWTF I suppose. It doesn’t do the actual job scheduling like whenever et al. Its designed really to be integrated into projects like whenever to make the syntax as straight forward as possible.
You can also just use it in the command line or irb to output the cron string to paste into crontab as a sanity check. Its evolving as I use it or see ways to tweak it.
by Lake Denman on 27 Mar 13:53
I’ve been using Whenever lately as a cron job manager for my rails app.
Check it out: http://github.com/javan/whenever/tree/master
by Valter on 13 Apr 08:22
Your plugin seems to be better than whenever lately. Ill give it a try in my cirurgia plastica blog.