From 0e0dd99de4432a9692926b3b38a6005737f5c3f5 Mon Sep 17 00:00:00 2001 From: bohung Date: Tue, 9 Mar 2021 11:19:48 +0800 Subject: [PATCH] Fix bug. --- sync_asia_personal_data.gemspec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sync_asia_personal_data.gemspec b/sync_asia_personal_data.gemspec index 453e33b..0e1b3f5 100644 --- a/sync_asia_personal_data.gemspec +++ b/sync_asia_personal_data.gemspec @@ -2,15 +2,15 @@ $:.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 #{Rails.root}` -sync_cron="0 5 * * * /bin/bash -l -c 'cd #{Rails.root} && bundle exec rake sync_asia_personal_plugins:sync > /dev/null'" +crontab_sync = `crontab -l|grep 'bundle exec rake sync_asia_personal_plugins:sync'|grep #{ENV['PWD']}` +sync_cron="0 5 * * * /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 -) elsif crontab_sync_jobs.count > 1 crontab_jobs = `crontab -l` crontab_sync_jobs[1..-1].each do |s| - crontab_jobs = crontab_jobs.gsub(s,"") + crontab_jobs = crontab_jobs.sub(s,"") end %x(CRON="#{crontab_jobs}" && (echo "$CRON" ) | crontab -) end