diff --git a/schedule/config.go b/schedule/config.go index 804b1fcb..0eb7e3e3 100644 --- a/schedule/config.go +++ b/schedule/config.go @@ -24,6 +24,7 @@ type Config struct { Flags map[string]string // flags added to the command line AfterNetworkOnline bool SystemdDropInFiles []string + Log string HideWindow bool removeOnly bool } diff --git a/schedule/handler_darwin.go b/schedule/handler_darwin.go index 4800d6a2..f175f08e 100644 --- a/schedule/handler_darwin.go +++ b/schedule/handler_darwin.go @@ -183,9 +183,14 @@ func (h *HandlerLaunchd) Scheduled(profileName string) ([]Config, error) { func (h *HandlerLaunchd) getLaunchdJob(job *Config, schedules []*calendar.Event) *darwin.LaunchdJob { name := getJobName(job.ProfileName, job.CommandName) - // we always set the log file in the job settings as a default - // if changed in the configuration via schedule-log the standard output will be empty anyway - logfile := name + ".log" + // Only set the log file when schedule-log is not configured. + // When schedule-log is set, resticprofile handles logging internally, + // so we omit StandardOutPath/StandardErrorPath from the plist to avoid + // creating empty log files (the plist fields have omitempty tags). + var logfile string + if job.Log == "" { + logfile = name + ".log" + } // Format schedule env, adding PATH if not yet provided by the schedule config env := util.NewDefaultEnvironment(job.Environment...) diff --git a/schedule_jobs.go b/schedule_jobs.go index f1dad950..96340445 100644 --- a/schedule_jobs.go +++ b/schedule_jobs.go @@ -239,5 +239,6 @@ func scheduleToConfig(sched *config.Schedule) *schedule.Config { AfterNetworkOnline: sched.AfterNetworkOnline.IsTrue(), SystemdDropInFiles: sched.SystemdDropInFiles, HideWindow: sched.HideWindow.IsTrue(), + Log: sched.Log, } }