Skip to content

Commit 0b7b254

Browse files
authored
Merge pull request #6 from BuaBook/issue-1
cron: Fix self cancelling a job [#1]
2 parents 137d5fa + 6a0148d commit 0b7b254

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/cron.q

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@
174174
.cron.i.runOnce:{[jobId]
175175
status:.cron.i.run jobId;
176176

177-
update nextRunTime:0Wp from `.cron.jobs where id = jobId;
177+
.cron.cancelJob jobId;
178178

179179
:status;
180180
};
@@ -187,10 +187,16 @@
187187

188188
jobDetails:.cron.jobs jobId;
189189

190+
if[.type.isInfinite jobDetails`nextRunTime;
191+
.log.debug "Job has been self-cancelled. Will not reschedule [ Job: ",string[jobId]," ]";
192+
:status;
193+
];
194+
190195
newNextRunTime:(+). jobDetails`nextRunTime`interval;
191196

192197
$[newNextRunTime > jobDetails`endTime;
193198
update nextRunTime:0Wp from `.cron.jobs where id = jobId;
199+
/ else
194200
update nextRunTime:newNextRunTime from `.cron.jobs where id = jobId
195201
];
196202

0 commit comments

Comments
 (0)