Class: Flydata::Cron

Inherits:
Object
  • Object
show all
Defined in:
lib/flydata/cron.rb

Constant Summary collapse

CRON_TMP_PATH =
"#{FLYDATA_HOME}/cron_list.tmp"
CRON_BACKUP_PATH =
"#{FLYDATA_HOME}/cron_list.back"
LOG_PATH =
"#{FLYDATA_HOME}/flydata_cron.log"
ROUTINE_BASE_COMMAND =
"#{FLYDATA_HOME}/bin/flydata routine >> #{LOG_PATH} 2>&1"
ROUTINE_COMMAND =
ROUTINE_BASE_COMMAND
CRON_LINE =
"15 4 * * * #{ROUTINE_COMMAND}"
REMOVE_OPTION =

CRON_LINE=“* * * * * #ROUTINE_COMMAND

"-r"

Instance Method Summary collapse

Constructor Details

#initializeCron

Returns a new instance of Cron.


17
18
# File 'lib/flydata/cron.rb', line 17

def initialize
end

Instance Method Details

#update(option = nil) ⇒ Object


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/flydata/cron.rb', line 19

def update(option=nil)
  arg = option ? option : ''

  # Check condition
  check_crontab_command
  dump_cron_setting
  reagistered = check_cron_setting

  # Remove mode
  if arg == REMOVE_OPTION
    unless reagistered
      puts "Skip removing. There are no flydata jobs in crontab."
    else
      remove_cron_setting
      puts "Updated crontab to remove the deletion of your log data."
    end
  # Add mode
  else
    if reagistered
      puts "Skip register. Already cron setup done."
    else
      add_cron_setting
      puts "Updated crontab to manage the deletion of your log data."
    end
  end
  true
end