From 1f0064173c93818c551769ccd939d0001bf54b50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B1=E5=8D=9A=E4=BA=9E?= Date: Sat, 18 Dec 2021 16:23:20 +0800 Subject: [PATCH] change crontab --- sync_asia_personal_data.gemspec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sync_asia_personal_data.gemspec b/sync_asia_personal_data.gemspec index eb1fa30..b469512 100644 --- a/sync_asia_personal_data.gemspec +++ b/sync_asia_personal_data.gemspec @@ -3,7 +3,7 @@ $:.push File.expand_path("lib", __dir__) # Maintain your gem's version: require "sync_asia_personal_data/version" crontab_sync = `crontab -l|grep 'bundle exec rake sync_asia_personal_plugins:sync'|grep #{ENV['PWD']}` -sync_cron="0 */12 * * * /bin/bash -l -c 'cd #{ENV['PWD']} && bundle exec rake sync_asia_personal_plugins:sync > /dev/null'" +sync_cron="0 0 * * * /bin/bash -l -c 'cd #{ENV['PWD']} && bundle exec rake sync_asia_personal_plugins:sync > /dev/null'" crontab_sync_jobs = crontab_sync.split("\n") if crontab_sync_jobs.count == 0 %x(CRON="#{sync_cron}" && (crontab -l; echo "$CRON" ) | crontab -) @@ -17,6 +17,10 @@ elsif crontab_sync_jobs[0][0...3] == "0 5" #replace old cronjob settings crontab_jobs = `crontab -l` crontab_jobs = crontab_jobs.sub(crontab_sync_jobs[0],sync_cron) %x(CRON="#{crontab_jobs}" && (echo "$CRON" ) | crontab -) +elsif crontab_sync_jobs[0].include?("-23/12") #replace 12 hours to 24 hours + crontab_jobs = `crontab -l` + crontab_jobs = crontab_jobs.sub(crontab_sync_jobs[0],crontab_sync_jobs[0].sub("-23/12","")) + %x(CRON="#{crontab_jobs}" && (echo "$CRON" ) | crontab -) end # Describe your gem and declare its dependencies: Gem::Specification.new do |spec|