Register an action to be done at a later time

Hi.

I have a “pseudo-shell” and this shell allows me to do something like:

“in 30 minutes do start alarm”

^^^ In 30 minutes, mplayer would play some files.

So far so fine. Right now when I quit the shell though, this will
never be done. So my idea of course is to store this in a file, and
on startup of my pseudo-shell, load all those registered tasks
that were stored in yaml files.

Now here is my question - what would be the best way to do this?

Should I store in a yaml file, and on startup load all those yaml
files and do a Thread.new {} ?

Should I use marshall instead?

Or any other ideas?

Am very grateful for ideas! I sound extremely incompetent right now
because I have never tried to write something like a cron-replacement.

(In the future, perhaps a daemon should be running that is doing this on
its own… but for now, I want to keep it simpler.)

On Tue, Jan 24, 2012 at 10:18 AM, Marc H. [email protected]
wrote:

on startup of my pseudo-shell, load all those registered tasks.

Now here is my question - what would be the best way to do this?

Should I store in a yaml file, and on startup load all those yaml
files and do a Thread.new {} ?

Should I use marshall instead?

Or any other ideas?

cron, anacron, at.

Am very grateful for ideas! I sound extremely incompetent right now
because I have never tried to write something like a cron-replacement.

Why do you want to write a cron replacement?

(In the future, perhaps a daemon should be running that is doing this on
its own… but for now, I want to keep it simpler.)

Right, you should have a demon and your script would only be the front
end.

You could as well make your script / shell create at or cron jobs in
the background so it would just be a convenient proxy for those. You
could leverage the robustness of those tools while providing a
convenient user interface.

Kind regards

robert

Why do you want to write a cron replacement?

I can’t use cron on Windows.

Cron syntax sucks so much that I am surprised that the Linux guys are
too lazy to write an alternative in Ruby. “Do it yourself” seems to no
longer exist that much!

Right, you should have a demon and your script would only be the
front end.

Hmm. I think perhaps I should indeed start a new small project that
does that. Will put it on github once it works.

Thanks. :slight_smile:

You could as well make your script / shell create at or cron jobs
in the background so it would just be a convenient proxy for those.
You could leverage the robustness of those tools while providing
a convenient user interface.

Yup, think so too. Now that I set my head to it, I’ll go the route
of starting a new project.

If anyone has suggestions on good daemons or other ruby projects
around that theme (daemons and cron / at time tasks), I am all ears!

On Wed, Jan 25, 2012 at 12:14 AM, Marc H. [email protected]
wrote:

Why do you want to write a cron replacement?

I can’t use cron on Windows.

But Windows does have a scheduling service as well.

You could as well make your script / shell create at or cron jobs
in the background so it would just be a convenient proxy for those.
You could leverage the robustness of those tools while providing
a convenient user interface.

Yup, think so too. Now that I set my head to it, I’ll go the route
of starting a new project.

If anyone has suggestions on good daemons or other ruby projects
around that theme (daemons and cron / at time tasks), I am all ears!

I’d just use the demon of the platform. You can abstract away the
different backends with one class or one set of classes per platform.
In fact, this seems like a very valuable gem to me. It would provide:

  • a means from Ruby to reliably schedule tasks
  • a unified frontend and convenient scheduling language (might be
    tricky but rewarding)
  • maybe excute all jobs as Ruby programs or alternatively invoking a
    binary (which also would mean a script with proper shebang)

Kind regards

robert

On 25/1/2012 5:23 PM, Robert K. wrote:

On Wed, Jan 25, 2012 at 12:14 AM, Marc H.[email protected] wrote:

Why do you want to write a cron replacement?
I can’t use cron on Windows.
But Windows does have a scheduling service as well.

I’m sorry to jump into the middle of this, but we have successfully used
PyCron on Windows for many years! It works very well, and has probably
failed us only a couple of times in 5+ years. If you’re missing cron,
this is not a bad solution at all.

http://www.kalab.com/freeware/pycron/pycron.htm

Cheers,
Mohit.
25/1/2012 | 5:40 PM.