Tcl Library Source Code

Bounty program for improvements to Tcl and certain Tcl packages.

[ Main Table Of Contents | Table Of Contents | Keyword Index | Categories | Modules | Applications ]


cron - Tool for automating the period callback of commands

Table Of Contents


package require Tcl 8.6
package require cron ?2.1?

::cron::at ?processname? timecode command
::cron::cancel processname
::cron::every processname frequency command
::cron::in ?processname? timecode command
::cron::object_coroutine object coroutine ?info?
::cron::sleep milliseconds
::cron::task delete process
::cron::task exists process
::cron::task info process
::cron::task set process field value ?field...? ?value...?
::cron::wake ?who?
::cron::clock_step milliseconds
::cron::clock_delay milliseconds
::cron::clock_sleep seconds ?offset?
::cron::clock_set newtime


The cron package provides a Pure-tcl set of tools to allow programs to schedule tasks to occur at regular intervals. Rather than force each task to issue it's own call to the event loop, the cron system mimics the cron utility in Unix: on task periodically checks to see if something is to be done, and issues all commands for a given time step at once.

Changes in version 2.0

While cron was originally designed to handle time scales > 1 second, the latest version's internal understand time granularity down to the millisecond, making it easier to integrate with other timed events. Version 2.0 also understands how to properly integrate coroutines and objects. It also adds a facility for an external (or script driven) clock. Note that vwait style events won't work very well with an external clock.


Several utility commands are provided that are used internally within cron and for testing cron, but may or may not be useful in the general cases.

Bugs, Ideas, Feedback

This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category odie of the Tcllib Trackers. Please also report any ideas for enhancements you may have for either package and/or documentation.

When proposing code changes, please provide unified diffs, i.e the output of diff -u.

Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar.


cron, odie




Copyright © 2016-2018 Sean Woods