fixed runCommand

This commit is contained in:
Niklas 2020-10-27 22:17:37 +01:00
parent 21c99ce8f6
commit 1b14fcbea4

View File

@ -140,12 +140,13 @@ func block(config sunsetConfig, command string) {
nextHr, nextMin := getNextWait(config) nextHr, nextMin := getNextWait(config)
timer := time.NewTimer((time.Duration(nextHr) * time.Hour) + (time.Duration(nextMin) * time.Minute)) timer := time.NewTimer((time.Duration(nextHr) * time.Hour) + (time.Duration(nextMin) * time.Minute))
<-timer.C <-timer.C
log.Printf("Running command: %s\n", command)
go runCommand(command) go runCommand(command)
} }
} }
func runCommand(command string) { func runCommand(command string) {
cmd := exec.Command("/usr/bin/env sh", "-c", command) cmd := exec.Command("/usr/bin/env", "sh", "-c", command)
err := cmd.Run() err := cmd.Run()
if err != nil { if err != nil {
log.Printf("Command %s returned a non 0 code", command) log.Printf("Command %s returned a non 0 code", command)