summaryrefslogtreecommitdiff
path: root/monoton.go
diff options
context:
space:
mode:
authorhorus_arch2015-03-15 20:51:57 +0100
committerhorus_arch2015-03-15 20:51:57 +0100
commitf964301365c314b388314551f73ea69e9e51df47 (patch)
tree3b9f0fd9ddceac8dae3d261f71a315e10a22c359 /monoton.go
parentfa9dd55107dd08830b2dc5e4cf52674ff19981cf (diff)
downloadmonotond-master.tar.gz
Replace -vars flag with -argsHEADmaster
Diffstat (limited to 'monoton.go')
-rw-r--r--monoton.go57
1 files changed, 0 insertions, 57 deletions
diff --git a/monoton.go b/monoton.go
deleted file mode 100644
index f52c797..0000000
--- a/monoton.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package main
-
-import (
- "flag"
- "fmt"
- "github.com/robfig/cron"
- "log"
- "os"
- "os/exec"
-)
-
-func main() {
- time_f := flag.String("time", "1m", "Set the time interval.")
- cmd_f := flag.String("cmd", "", "Execute the command.")
- vars_f := flag.String("vars", "", "Command line options for the programm.")
-
- flag.Parse()
- var (
- time, cmd, vars string
- )
-
- time = fmt.Sprintf("@every %s", *time_f)
- cmd = fmt.Sprintf("%s", *cmd_f)
- vars = fmt.Sprintf("%s", *vars_f)
-
- cmd, err := exec.LookPath(cmd)
- if err != nil {
- log.Printf("Executable (%s) neither found in PATH variable nor in working directory.\n", *cmd_f)
- os.Exit(1)
- }
-
- job := cron.New()
- job.AddFunc(time, func() {
-
- if vars == "" {
- c := exec.Command(cmd)
- o, err := c.Output()
- if err != nil {
- log.Println(err)
- }
- fmt.Printf("%s", o)
- } else {
- c := exec.Command("bash", "-c", cmd+" "+vars)
- o, err := c.Output()
- if err != nil {
- log.Println(err)
- }
- fmt.Printf("%s", o)
- }
-
- })
- job.Start()
-
- for {
- select {}
- }
-}