Class: Backups::Crontab
- Inherits:
-
Object
- Object
- Backups::Crontab
- Defined in:
- lib/backups/crontab.rb
Constant Summary collapse
- PADDING =
10
Constants included from Loader
Loader::CONFIG_ENV, Loader::CONFIG_SYSTEM, Loader::CONFIG_USER
Instance Method Summary collapse
-
#initialize ⇒ Crontab
constructor
A new instance of Crontab.
- #install ⇒ Object
- #list ⇒ Object
- #show ⇒ Object
Methods included from Loader
Methods included from System
#delete, #delete_dir, #exec, #get_latest_s3, #mkdir, #nuke_dir, #write
Constructor Details
#initialize ⇒ Crontab
Returns a new instance of Crontab.
11 12 13 14 |
# File 'lib/backups/crontab.rb', line 11 def initialize load_configs @base = File.('../../..', __FILE__) end |
Instance Method Details
#install ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/backups/crontab.rb', line 43 def install last_log_active = $LOG_ACTIVE $LOG_ACTIVE = 0 install_mysql_groups content = get_install_lines() cronfile = "/tmp/crontab.new" write cronfile, content exec "crontab #{cronfile}" exec "rm #{cronfile}" exec "crontab -l" $LOG_ACTIVE = last_log_active end |
#list ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/backups/crontab.rb', line 16 def list paddings = { 'job' => 20, 'backup' => 10, 'verify' => 10, } rows = [] rows << ["JOB", "CRONTAB", "INSTALL", "ENABLED"] $GLOBAL["jobs"].each do |job, config| backup = config.fetch('backup', {}) crontab = backup.fetch('crontab', {}) crontime = get_crontime(crontab) install = crontab.fetch('install', true) enabled = config.fetch('enabled', true) rows << [job, crontime, install, enabled] end Tablelize::table rows end |
#show ⇒ Object
39 40 41 |
# File 'lib/backups/crontab.rb', line 39 def show get_install_lines() end |