1
0
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:
nxshock 2024-03-28 09:33:15 +05:00
parent 48370480b1
commit 8a4b8e6b50
2 changed files with 4 additions and 1 deletions

View File

@ -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)

4
job.go
View File

@ -25,7 +25,8 @@ type JobConfig struct {
Category string Category string
// 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()
} }