If you have an Abort[] inside a ScheduledTask expression, what does it abort? The scheduled task evaluation, or any main kernel evaluation that is ongoing?

  • 1
    $\begingroup$ have you tried it? $\endgroup$ Commented Dec 6, 2013 at 15:57
  • 1
    $\begingroup$ Yes, and I know the answer. I'm contributing this question which came to me from a Mathematica user because (a) it's not necessarily obvious what it should do and (b) it's not currently documented. $\endgroup$
    – Joel Klein
    Commented Dec 6, 2013 at 22:27
  • $\begingroup$ My guess/expectation is that it would only abort whatever is being evaluated in the task. What is the answer? $\endgroup$ Commented Dec 6, 2013 at 22:32
  • 1
    $\begingroup$ I tried and it only aborts the task. An explanation would be nice since you know the internals :-) How does this functionality even work? Does it depend on anything outside of the kernel (e.g. Java)? Are these pre-emptive evaluations (like Button by default)? Is the functionality exactly the same as Internal`Periodicals or different? $\endgroup$
    – Szabolcs
    Commented Dec 7, 2013 at 0:48
  • 1
    $\begingroup$ It is strongly recommended to self answer, the more that your answer would be the most reliable here :) $\endgroup$
    – Kuba
    Commented Dec 7, 2013 at 9:44

1 Answer 1


Abort[] inside a scheduled task will abort the rest of the task expression at the given time, not any main evaluation. It will also repeat to evaluate the task (up till the Abort[]) if further time slots are scheduled.

To show this, first start a scheduled task:

 Print[DateString[], " Scheduled task before Abort[]"]; Abort[]; 
 Print[DateString[], " Scheduled task after Abort[]"], {5, 3}, 5]

By itself you can see that the scheduled task expression gets aborted: in the Messages window you will see the "before" Print output, but not the "after".

While this is running, start a long-running evaluation in a cell:

Print["Mersenne primes:"]; 
   With[{n = 2^i - 1, i = i}, 
      If[PrimeQ[n], Print[HoldForm[2^i - 1 == n]]]
   {i, 10^6}

This keeps evaluating even when the scheduled task issues its Abort.

  • $\begingroup$ I have included some clarification, hope you don't mind! $\endgroup$ Commented Dec 10, 2013 at 20:51
  • $\begingroup$ That's great, thank you! $\endgroup$
    – Joel Klein
    Commented Dec 10, 2013 at 22:21
  • $\begingroup$ @JoelKlein After starting the long-running evaluation I do not see messages from the ScheduledTask no more (I use v. 8.0.4). Why this happens? $\endgroup$ Commented Dec 13, 2013 at 19:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.