I want to know the command that is executed after a certain period of time.

I guess Pause is a good choice for my purpose. For instance, I tried to let the Mathematica do a job after 5 hours:

Pause[3600*5 (* 3600 seconds is 1 hour *)]

This code does not work, because after 5 hours I saw Mathematica was still pausing!

I confirmed the above code works if I choose a time around few minutes.

Any ideas would be appreciated, thank you.

  • $\begingroup$ Which Mathematica version do you use? I don't have this problem with version 13.0.0 on Windows 10 x64: screenshot. $\endgroup$ Jan 23 at 14:13
  • 1
    $\begingroup$ I am using version 12.3.1 on Mac OS Big Sur. I saw your screenshot. Your code runs after only 5min. I guess that my PC will be in sleep mode when leaving it for 5 "hours". I expect that I don't have this problem if I turn off the sleep mode. $\endgroup$ Jan 24 at 8:56
  • $\begingroup$ Probably with RunScheduledTask you will have the same problem when the PC will be in sleep mode... $\endgroup$ Jan 24 at 9:08
  • 1
    $\begingroup$ That 's right. Now, I realized that the problem was not in a specific command in mathematica, but in sleep mode... $\endgroup$ Jan 25 at 1:49

1 Answer 1


You can use scheduled tasks. Also, they do not hold up processing while waiting to activate : As demonstrated below, x continues to update while the message displays and then disappears.

x = 0;

  message = CreateDialog[TextCell[Style[
      "\n      Your message here.      \n\n", 18]],
    WindowFloating -> True];
  RunScheduledTask[NotebookClose[message], {1.5}]];
 Array[If[Mod[#, 100] == 0, x = #] &, 2000000];]
  • $\begingroup$ "RunScheduledTask" works fine! Thank you for your help! $\endgroup$ Jan 23 at 3:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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