RunScheduledTask

RunScheduledTask is being phased out in favor of TaskExecute, which was introduced experimentally in Version 11.2.

RunScheduledTask[expr]

schedules and starts a local scheduled task that will repeatedly evaluate expr once per second.

RunScheduledTask[expr,time]

schedules and starts a task that will repeatedly evaluate expr every time seconds.

RunScheduledTask[expr,{time}]

schedules and starts a task that will evaluate expr once after time seconds.

RunScheduledTask[expr,{time,count}]

schedules and starts a task that will try evaluating expr once every time seconds up to count times.

RunScheduledTask[expr,timespec,start]

schedules a task that will automatically start at start time.

RunScheduledTask[CloudObject[]]

asynchronously executes an existing cloud task or document generator.

Details and Options

  • For local tasks, RunScheduledTask returns a ScheduledTaskObject expression representing the started task. For cloud tasks and document generators, RunScheduledTask returns the task's CloudObject.
  • RunScheduledTask creates a task to be run locally in the current Wolfram Language session. No task state is preserved between sessions.
  • RunScheduledTask[x] is effectively equivalent to StartScheduledTask[CreateScheduledTask[x]].
  • The start is taken to be the absolute time when the task is activated.
  • The first evaluation of expr will occur time seconds after it is activated.
  • If two tasks are scheduled to evaluate at the same time, the one added later will execute first.
  • By default, if the time necessary to evaluate expr is larger than time, the next pending evaluation is skipped.

Examples

open allclose all

Basic Examples  (11)

The timer fires off at the end of the specified three-second interval:

Perform an action the specified number of times:

Create a task that will be activated 5 seconds from the current time and will print 1 second later:

Specify a date to activate the task:

Front end versus kernel clocks:

Create a task with random wait periods:

Create a task that restarts evaluation as soon as it finishes:

Create a task that runs only once and removes itself after finishing:

Create a task that removes itself once a condition is met:

Create a task that removes itself when an external variable is changed:

Cause the task to be stopped and removed:

Control evaluation in the scheduled task by changing an external variable:

Pause the evaluation without stopping the task:

Re-enable the evaluation:

Scope  (2)

RunScheduledTask causes cloud scheduled tasks to evaluate asynchronously, as for calendar-triggered evaluations:

Trigger the task to run asynchronously:

Delete the task:

RunScheduledTask causes document generators to evaluate asynchronously. Logging, distribution, and archiving occur as for calendar-triggered evaluations:

Trigger the generator to run asynchronously:

Delete the generator:

Options  (1)

GeneratedDocumentBinding  (1)

Use the GeneratedDocumentBinding option to override a document generator's configured driver. Deploy a document generator:

Trigger the generator to run asynchronously, overriding the driver:

Delete the generator:

Possible Issues  (1)

RunScheduledTask has attribute HoldFirst and will interpret cloud object arguments as expressions to be evaluated in a local scheduled task:

This will evaluate obj once per second in a local scheduled task:

Delete the local task:

A With or Apply construct ensures cloud execution:

Delete the cloud task:

Wolfram Research (2010), RunScheduledTask, Wolfram Language function, https://reference.wolfram.com/language/ref/RunScheduledTask.html (updated 2014).

Text

Wolfram Research (2010), RunScheduledTask, Wolfram Language function, https://reference.wolfram.com/language/ref/RunScheduledTask.html (updated 2014).

CMS

Wolfram Language. 2010. "RunScheduledTask." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/RunScheduledTask.html.

APA

Wolfram Language. (2010). RunScheduledTask. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RunScheduledTask.html

BibTeX

@misc{reference.wolfram_2024_runscheduledtask, author="Wolfram Research", title="{RunScheduledTask}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/RunScheduledTask.html}", note=[Accessed: 18-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_runscheduledtask, organization={Wolfram Research}, title={RunScheduledTask}, year={2014}, url={https://reference.wolfram.com/language/ref/RunScheduledTask.html}, note=[Accessed: 18-November-2024 ]}