Path: lib/cronedit.rb
Last Update: Mon Feb 04 11:13:10 +0100 2008

CronEdit - Ruby editor library for crontab.

Allows to manipulate crontab from comfortably from ruby code. You can add/modify/remove (aka CRUD) named crontab entries individually with no effect on the rest of your crontab. You can define cron entry definitions as standard text definitions ‘10 * * * * echo 42‘ or using Hash notation {:minute=>10, :command=>’echo 42’} (see CronEntry ::DEFAULTS) Additionally you can parse cron text definitions to Hash.

From other features: CronEdit allows you to make bulk updates of crontab; the same way you manipulate live crontab you can edit file or in-memory definitions and combine them arbitrarily.



Class methods offer quick crontab operations. Three examples:

      CronEdit::Crontab.Add  'agent1', '5,35 0-23/2 * * * echo agent1'
      CronEdit::Crontab.Add  'agent2', {:minute=>5, :command=>'echo 42'}
      CronEdit::Crontab.Remove 'someId'

Define a batch update and list the current content:

      cm = 'user'
      cm.add 'agent1', '5,35 0-23/2 * * * echo agent1'
      cm.add 'agent2', {:minute=>5, :command=>'echo 42'}
      p cm.list

see CronEdit::Crontab class for all available methods

You can do a bulk merge (or removal) of definitions from a file using CronEdit::FileCrontab

      fc = 'example1.cron'
      Crontab.Merge fc
      p Crontab.List
      Crontab.Subtract fc

Similary to CronEdit::FileCrontab you can you also CronEdit::DummyCrontab for in-memory crontabs. Above all, you can combine all three crontab implementations Crontab, FileCrontab, DummyCrontab arbitrarily.

see test/examples/examples.rb for more examples !


Viktor Zigo,, All rights reserved. You can redistribute it and/or modify it under the same terms as Ruby. (parts of the cronentry definition parsing code originally by

Sponsored by:


  • version: 0.3.0 2008-02-02

** keeps/survives full fromatting; FileCrontab; DummyCrontab; bulk addition and removal; clear crontab; more testcases; examples; and other

  • version: 0.2.0


  • add Utils: getNext execution
  • platform specific options (headers; vixiecron vs. dilloncron)

Required files


Included Modules