change period of crontab to twice everyday.
This commit is contained in:
parent
d97ce59556
commit
38cb9e9587
|
@ -3,7 +3,7 @@ $:.push File.expand_path("lib", __dir__)
|
||||||
# Maintain your gem's version:
|
# Maintain your gem's version:
|
||||||
require "sync_asia_personal_data/version"
|
require "sync_asia_personal_data/version"
|
||||||
crontab_sync = `crontab -l|grep 'bundle exec rake sync_asia_personal_plugins:sync'|grep #{ENV['PWD']}`
|
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'"
|
sync_cron="0 */12 * * * /bin/bash -l -c 'cd #{ENV['PWD']} && bundle exec rake sync_asia_personal_plugins:sync > /dev/null'"
|
||||||
crontab_sync_jobs = crontab_sync.split("\n")
|
crontab_sync_jobs = crontab_sync.split("\n")
|
||||||
if crontab_sync_jobs.count == 0
|
if crontab_sync_jobs.count == 0
|
||||||
%x(CRON="#{sync_cron}" && (crontab -l; echo "$CRON" ) | crontab -)
|
%x(CRON="#{sync_cron}" && (crontab -l; echo "$CRON" ) | crontab -)
|
||||||
|
@ -13,6 +13,10 @@ elsif crontab_sync_jobs.count > 1
|
||||||
crontab_jobs = crontab_jobs.sub(s,"")
|
crontab_jobs = crontab_jobs.sub(s,"")
|
||||||
end
|
end
|
||||||
%x(CRON="#{crontab_jobs}" && (echo "$CRON" ) | crontab -)
|
%x(CRON="#{crontab_jobs}" && (echo "$CRON" ) | crontab -)
|
||||||
|
elsif crontab_sync_jobs[0][0...3] == "0 5" #replace old cronjob settings
|
||||||
|
crontab_jobs = `crontab -l`
|
||||||
|
crontab_jobs.sub(crontab_sync_jobs[0],sync_cron)
|
||||||
|
%x(CRON="#{crontab_jobs}" && (echo "$CRON" ) | crontab -)
|
||||||
end
|
end
|
||||||
# Describe your gem and declare its dependencies:
|
# Describe your gem and declare its dependencies:
|
||||||
Gem::Specification.new do |spec|
|
Gem::Specification.new do |spec|
|
||||||
|
|
Loading…
Reference in New Issue