Skip to content

Commit

Permalink
full path in crontab
Browse files Browse the repository at this point in the history
  • Loading branch information
inv2004 committed Jan 10, 2023
1 parent 9d0ccae commit 73ec144
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/ttop/onoff.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const timer = "*:0/10:08"
const unit = "ttop"
const descr = "ttop service snapshot collector"

const cron = "*/10 * * * * ttop -s"
const cron = "*/10 * * * *"

const options = {poUsePath, poEchoCmd, poStdErrToStdOut}

Expand Down Expand Up @@ -93,15 +93,16 @@ proc onOffSystemd(enable: bool) =

proc filter(input: string): string =
for l in input.splitLines(true):
if "ttop" in l:
if unit in l:
continue
result.add l

proc onOffCron(enable: bool) =
let output = cmd("crontab -l", true)
var input = filter(output)
if enable:
input &= cron & "\n"
let app = getAppFilename()
input &= &"{cron} {app} -s\n"
discard cmd("crontab", false, input)
else:
if input == "":
Expand Down

0 comments on commit 73ec144

Please sign in to comment.