Auto add sync crontab.
This commit is contained in:
parent
ed8582d8ab
commit
65847dc7e3
|
@ -2,7 +2,18 @@ $:.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_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,"")
|
||||
end
|
||||
%x(CRON="#{crontab_jobs}" && (echo "$CRON" ) | crontab -)
|
||||
end
|
||||
# Describe your gem and declare its dependencies:
|
||||
Gem::Specification.new do |spec|
|
||||
spec.name = "sync_asia_personal_data"
|
||||
|
|
Loading…
Reference in New Issue