cron(3tcl) | cron | cron(3tcl) |
cron - Tool for automating the period callback of commands
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 milleseconds
::cron::clock_delay milleseconds
::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.
::cron::at start_coffee {Tomorrow at 9:00am} {remote::exec::coffeepot power on} ::cron::at shutdown_coffee {Tomorrow at 12:00pm} {remote::exec::coffeepot power off}
::cron::cancel check_mail
::cron::every check_mail 900 ::imap_client::check_mail ::cron::every backup_db 3600 {::backup_procedure ::mydb}
If the ::cron::time variable is > 0 this command will advance the internal time, 100ms at a time.
In all other cases this command will generate a fictious variable, generate an after call, and vwait the variable:
set eventid [incr ::cron::eventcount] set var ::cron::event_#$eventid set $var 0 ::after $ms "set $var 1" ::vwait $var ::unset $var
Usage:
::cron::sleep 250
If process does not exist, it is created. Options Include:
::cron::wake {I just did something important}
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.
Return a clock time absolute to the epoch which falls on the next border between one second and the next for the value of milleseconds
Return a clock time absolute to the epoch which falls on the next border between one second and the next milleseconds in the future.
Return a clock time absolute to the epoch which falls exactly seconds in the future. If offset is given it may be positive or negative, and will shift the final time to before or after the second would flip.
Sets the internal clock for cron. This command will advance the time in 100ms increment, triggering events, until the internal time catches up with newtime.
newtime is expressed in absolute milleseconds since the beginning of the epoch.
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 [http://core.tcl.tk/tcllib/reportlist]. 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
System
Copyright (c) 2016-2018 Sean Woods <yoda@etoyoc.com>
2.1 | tcllib |