Module: CronEdit

Defined in:
lib/cronedit.rb

Overview

:title:CronEdit - Ruby editior library for cron and crontab - RDoc documentation

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 standart text definitions '10 * * * * echo 42' or using Hash notation {:minute=>10, :command=>'echo 42'} (see CronEntry ::DEFAULTS) Additionaly you can parse cron text definitions to Hash.

Usage

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'

or define a batch update and list the current content:

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

see Crontab for all available methods

Author

Viktor Zigo, 7inf.com, All rights reserved. You can redistribute it and/or modify it under the same terms as Ruby. (parts of the cron definition parsing code originaly by [email protected])

History

version: 0.2.0

TODO

add more commands (clean crontab); lift some methods to class; put tests to separate file; make rake, make gem; implement addAllfrom add Utils: getNext execution

Defined Under Namespace

Classes: CronEntry, Crontab