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

# cron(n) 0.1 tcllib "cron"

## Name

cron - Tool for automating the period callback of commands

## Table Of Contents

## Synopsis

- package require Tcl 8.5
- package require cron ?0.1?

- ::cron::at ?processname? timecode command
- ::cron::cancel processname
- ::cron::every processname frequency command
- ::cron::in ?processname? timecode command

## Description

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. The cron package is intended to work in time scales greater than 1 second.

## Commands

::cron::at ?processname? timecode command

  This command registers a command to be called at the time specified by timecode. If timecode is expressed as an integer, the timecode is assumed to be in unixtime. All other inputs will be interpreted by clock scan and converted to unix time. This task can be modified by subsequent calls to this package's commands by referencing processname. If processname exists, it will be replaced. If processname is not given, one is generated and returned by the command.

      ::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 processname

  This command unregisters the process processname and cancels any pending commands. Note: processname can be a process created by either ::cron::at or ::cron::every.

      ::cron::cancel check_mail

::cron::every processname frequency command

  This command registers a command to be called at the interval of frequency. frequency is given in seconds. This task can be modified by subsequent calls to this package's commands by referencing processname. If processname exists, it will be replaced.

      ::cron::every check_mail 900  ::imap_client::check_mail
      ::cron::every backup_db  3600 {::backup_procedure ::mydb}

::cron::in ?processname? timecode command

  This command registers a command to be called after a delay of time specified by timecode. timecode is expressed as an seconds. This task can be modified by subsequent calls to this package's commands by referencing processname. If processname exists, it will be replaced. If processname is not given, one is generated and returned by the command.

## 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.

## Keywords

cron, odie

## Category

System

## Copyright

Copyright © 2015 Sean Woods <yoda@etoyoc.com>