mirror of
https://github.com/nxshock/gron.git
synced 2024-11-27 03:41:00 +05:00
Allow to set cmd working directory
This commit is contained in:
parent
48370480b1
commit
8a4b8e6b50
@ -4,6 +4,7 @@ Description = "print 'Hello' every minute" # job description
|
|||||||
Cron = "* * * * *" # cron instructions
|
Cron = "* * * * *" # cron instructions
|
||||||
|
|
||||||
Command = "echo Hello" # command to execute
|
Command = "echo Hello" # command to execute
|
||||||
|
WorkingDir = "/tmp" # working directory
|
||||||
|
|
||||||
NumberOfRestartAttemts = 3 # number of restart attemts
|
NumberOfRestartAttemts = 3 # number of restart attemts
|
||||||
RestartSec = 5 # the time to sleep before restarting a job (seconds)
|
RestartSec = 5 # the time to sleep before restarting a job (seconds)
|
||||||
|
2
job.go
2
job.go
@ -26,6 +26,7 @@ type JobConfig struct {
|
|||||||
|
|
||||||
// JobType = Cmd
|
// JobType = Cmd
|
||||||
Command string // command for execution
|
Command string // command for execution
|
||||||
|
WorkingDir string // working directory
|
||||||
|
|
||||||
// JobType = Sql
|
// JobType = Sql
|
||||||
Driver string
|
Driver string
|
||||||
@ -225,6 +226,7 @@ func (j *Job) runCmd(jobLogFile *os.File) error {
|
|||||||
cmd := exec.Command(command, params...)
|
cmd := exec.Command(command, params...)
|
||||||
cmd.Stdout = jobLogFile
|
cmd.Stdout = jobLogFile
|
||||||
cmd.Stderr = jobLogFile
|
cmd.Stderr = jobLogFile
|
||||||
|
cmd.Dir = j.JobConfig.WorkingDir
|
||||||
|
|
||||||
return cmd.Run()
|
return cmd.Run()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user