Creating Schedule Per Record

38 views
Skip to first unread message

si...@polkaspots.com

unread,
Aug 28, 2012, 2:25:39 PM8/28/12
to whenev...@googlegroups.com
We've been using whenever successfully for a while now but have run up against a slightly strange requirement.

Our Rails 3.2 app has several thousand 'customers' each with their own cron. The values for each cron are stored in the client's model and the crontab rendered as a text file. On boot, each client connects and downloads their own file. It's pretty cumbersome right now.

We were thinking to wheneverize this process as your logic and structure if far superior and easy to understand.

Have had a look at the various output options but we don't really want to render to a file. 

Do you think it would be possible for whenever to generate the file on the fly, each time the client calls in? The values would still be stored in the db.

Is there a better way to achieve this?

Javan Makhmali

unread,
Aug 28, 2012, 2:32:08 PM8/28/12
to whenev...@googlegroups.com
Currently, if you run whenever with no options, it will output your schedule file in cron syntax (but won't write anything to your crontab file). It would be pretty easy to patch whenever to read from stdin rather than a schedule.rb file, but that's not something it knows how to do now.

Is that what you mean?

-Javan


--
You received this message because you are subscribed to the Google
Groups "Whenever Gem" group and because you're awesome.
To post to this group, send email to whenev...@googlegroups.com
To unsubscribe from this group, send email to
whenever-gem...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/whenever-gem?hl=en

si...@polkaspots.com

unread,
Aug 28, 2012, 5:23:52 PM8/28/12
to whenev...@googlegroups.com
Not quite, I'm thinking the other way around. I have a cron template and each client has a number of jobs which run at different times of the day. The client variables are sucked out of the db when they get their crontab file.

Eg. 

Client 1

*/2 * * * * ruby /etc/scripts/heartbeat.rb
*/2 * * * * ruby /etc/scripts/ping.rb


Client 2 

*/10 * * * * ruby /etc/scripts/heartbeat.rb

Every client has a slightly different template. It works right now, it's just messy and I like your structure better. I.e.

Each client:

Every day at x do ...

Not sure if I'm being clear here!

Javan Makhmali

unread,
Aug 28, 2012, 6:42:58 PM8/28/12
to whenev...@googlegroups.com
Sounds like you could construct a temp file for each client, have whenever read that file with the --load-file option, and then delete the temp file when you're done.

-Javan

si...@polkaspots.com

unread,
Aug 29, 2012, 9:39:58 AM8/29/12
to whenev...@googlegroups.com
Yeah, might look at this. 

We're on a distributed network though with multiple servers - file handling can get a bit tricky.

S

Javan Makhmali

unread,
Aug 29, 2012, 11:35:05 AM8/29/12
to whenev...@googlegroups.com
That's why patching whenever to read from stdin might help you out. You could read each user's template and pipe that into whenever. No files needed.

-Javan

si...@polkaspots.com

unread,
Aug 30, 2012, 6:39:28 PM8/30/12
to whenev...@googlegroups.com
Going to have to rethink this. Yeah, will give that a shot..

Thanks
Reply all
Reply to author
Forward
0 new messages