Skip to content

Commit

Permalink
Handle duplicated job correctly in template
Browse files Browse the repository at this point in the history
  • Loading branch information
takumakanari committed Mar 24, 2019
1 parent 8fb1a09 commit 636823d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions example/crontab
Expand Up @@ -20,3 +20,8 @@ HOME=/
@reboot root /usr/bin/rebooted arg1 arg2
@reboot root /usr/bin/rebooted --arg1=val2
@hourly /usr/bin/somedirectory/some-hourly-command arg1 arg2

# duplicated jobs
00 10 * * * user /usr/bin/dup > /dev/null
10 17 * * * user /usr/bin/dup > /dev/null

2 changes: 1 addition & 1 deletion template.go
Expand Up @@ -57,7 +57,7 @@ const TEMPLATE = `
{{ $timeTo := .TimeTo }}
{{range $index, $cronv := .CronEntries}}
{{ $job := JSEscapeString $cronv.Crontab.Job }}
tasks['{{$job}}'] = [];
tasks['{{$job}}'] = tasks['{{$job}}'] || [];
{{if IsRunningEveryMinutes $cronv.Crontab }}
tasks['{{$job}}'].push(['{{$job}}', '', 'Every minutes {{$job}}', {{NewJsDate $timeFrom}}, {{NewJsDate $timeTo}}]);
{{else}}
Expand Down

0 comments on commit 636823d

Please sign in to comment.