From cc9a737d55c6cdffa1ba4b1a47499575ad86e93f Mon Sep 17 00:00:00 2001 From: Charles Peterson Date: Mon, 20 Nov 2017 09:25:22 -0600 Subject: [PATCH] Fix for cron.service: Start request repeated too quickly. (#725) * Update cron-schedule.sh restarts to often * Create cron-restart.sh only need to restart once. * Update homestead.rb restart cron daemon once to prevent homestead systemd[1]: cron.service: Start request repeated too quickly. https://laracasts.com/discuss/channels/servers/homestead-create-schedule-fails --- scripts/cron-restart.sh | 3 +++ scripts/cron-schedule.sh | 2 -- scripts/homestead.rb | 7 +++++++ 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 scripts/cron-restart.sh diff --git a/scripts/cron-restart.sh b/scripts/cron-restart.sh new file mode 100644 index 000000000..3e1a66907 --- /dev/null +++ b/scripts/cron-restart.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +service cron restart diff --git a/scripts/cron-schedule.sh b/scripts/cron-schedule.sh index 9cb2499e1..5443275a0 100755 --- a/scripts/cron-schedule.sh +++ b/scripts/cron-schedule.sh @@ -10,5 +10,3 @@ SITE_PUBLIC_DIRECTORY=$2 cron="* * * * * vagrant /usr/bin/php $SITE_PUBLIC_DIRECTORY/../artisan schedule:run >> /dev/null 2>&1" echo "$cron" > "/etc/cron.d/$SITE_DOMAIN" - -service cron restart diff --git a/scripts/homestead.rb b/scripts/homestead.rb index 19fdf954c..f4ed0dc32 100644 --- a/scripts/homestead.rb +++ b/scripts/homestead.rb @@ -184,6 +184,7 @@ def Homestead.configure(config, settings) end if settings.include? 'sites' + has_cron = false settings["sites"].each do |site| # Create SSL certificate @@ -220,6 +221,7 @@ def Homestead.configure(config, settings) if (site["schedule"]) s.path = scriptDir + "/cron-schedule.sh" s.args = [site["map"].tr('^A-Za-z0-9', ''), site["to"]] + has_cron = true else s.inline = "rm -f /etc/cron.d/$1" s.args = [site["map"].tr('^A-Za-z0-9', '')] @@ -233,6 +235,11 @@ def Homestead.configure(config, settings) end end end + # Restart cron daemon + if has_cron + config.vm.provision "shell" do |s| + s.path = scriptDir + "/cron-restart.sh" + end end config.vm.provision "shell" do |s|