mirror of
https://github.com/nxshock/gron.git
synced 2025-07-01 00:13:36 +05:00
Allow to set cmd working directory
This commit is contained in:
parent
48370480b1
commit
8a4b8e6b50
2 changed files with 4 additions and 1 deletions
|
@ -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)
|
||||
|
|
4
job.go
4
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()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue