module CronTools
  module Helper
    include Chef::Mixin::ShellOut

    def cron_existing?(cron)
      cmd = shell_out!("/bin/crontab -l | sed -e 's/#.*//;/^$/d'", returns: [0, 1, 2])
      cmd.stderr.empty? && cmd.stdout.include?(cron)
    end
  end
end
