Class: CrontabRb::Write

Inherits:
Object
  • Object
show all
Defined in:
lib/crontab_rb/write.rb

Class Method Summary collapse

Class Method Details

.write_crontabObject



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/crontab_rb/write.rb', line 3

def self.write_crontab
  contents = CrontabRb::Parse.from_database
  command = "crontab -"      
  IO.popen(command, 'r+') do |crontab|
    crontab.write(contents)
    crontab.close_write
  end
  success = $?.exitstatus.zero?
  if success
    puts "[write] crontab file updated"
  end
end