diff --git a/_jobExamples/advanced.conf b/_jobExamples/advanced.conf index cb4719d..d45d2b5 100644 --- a/_jobExamples/advanced.conf +++ b/_jobExamples/advanced.conf @@ -4,6 +4,7 @@ Description = "print 'Hello' every minute" # job description Cron = "* * * * *" # cron instructions Command = "echo Hello" # command to execute +WorkingDir = "/tmp" # working directory NumberOfRestartAttemts = 3 # number of restart attemts RestartSec = 5 # the time to sleep before restarting a job (seconds) diff --git a/job.go b/job.go index d648028..5cede9a 100644 --- a/job.go +++ b/job.go @@ -25,7 +25,8 @@ type JobConfig struct { Category string // JobType = Cmd - Command string // command for execution + Command string // command for execution + WorkingDir string // working directory // JobType = Sql Driver string @@ -225,6 +226,7 @@ func (j *Job) runCmd(jobLogFile *os.File) error { cmd := exec.Command(command, params...) cmd.Stdout = jobLogFile cmd.Stderr = jobLogFile + cmd.Dir = j.JobConfig.WorkingDir return cmd.Run() }