Crontab file cron.tab
The "heart" of nnCron LITE is a crontab file where all the data required to start an application is stored: starting time, frequency of its execution, application's name and parameters with with it should be run. Immediately after nnCron LITE is installed, a crontab file named cron.tab will be created in nnCron's installation directory. cron.tab is an ordinary text file. It can be created and/or edited in any available text editor.
Each minute, nnCron LITE checks time of last modification of cron.tab; if it notices that file was changed, it automatically "rereads" it. If you have manually changed some data in a crontab file and you don't want to wait while nnCron LITE reloads it automatically, you can hasten the process of crontab reloading by typing in command line:
cron.exe -reload
Syntax that is used in crontab files is very simple: in order to start an application, one only has to specify a desired time of startup in cron format and (after a blank space) the command that should be executed:
<time_in_cron_format> <command>
Comments in crontab files begin with character '#' and continue until the end of line. Crontab file may contain any number of empty lines, which are ignored by the parser. Leading spaces and tab characters are also ignored.
Example:
# application 'chime.exe' is started at 12:15 every week day 15 12 * * 1-5 d:\tools\chime.exe # the pdf file named in the task is opened daily # at 12:00 ad at 17:00 0 12,17 * * * e:\my documents\perl\re\re.pdf # the command file named in the task is executed every 5 minutes */5 * * * * d:\fido\bat\blstbbs.cmd
Please note two things:
Of course, that doesn't mean that you cannot enclose filenames with blank spaces between quotation marks or that you cannot call the command interpreter explicitly. Use the way which is more convenient to you:
0 12 * * * "e:\my documents\forth\index.html" 0 8-18 * * 1-5 cmd /c d:\tools\cleanup.bat
The aforementioned syntax is fully compatible with cron syntax, which is widely used in Unix world. In addition to this plain syntax nnCron LITE has several interesting extensions, which let you control how commands will be logged in nnCron LITE log-file and even let you to start full-blown scripts, written in Forth programming language.
Preventing Tasks from Beeing Logged fo a Log File
Let me remind you the plain crontab syntax:
<time_in_cron_format> <command>
If your application starts very often (say, every two minutes), nnCron LITE log-file becomes overcrowded very quickly. If you want to prevent some commands from beeing logged to a log-file, just prepend tilde symbol ('~') before these commands, like this:
<time_in_cron_format> ~<command>
Examples:
# this task will be logged to log-file 0 * * * * c:\test\reminder.bat # this task will not be logged to log-file */2 * * * * ~c:\test\reminder1.bat
Executing Scripts Written in Forth Programming Language
Using another symbol - exclamation point ('!') you can execute any Forth words as a command, which gives you a possibility to write and execute scripts, written in Forth programming Language (SP-Forth).
<time_in_cron_format> !<any Forth words until the end of line>
This is discussed in greater detail in chapter nnCron LITE and Forth Programing Language.
Sometimes tasks may have been missed because nnCron LITE was not running at the specified time. Prepend @-symbol before time in cron-format if you want to run missed task 'at the first opportunity' - at the top of the first minute after nnCron LITE startup:
@<time_in_cron_format> <command>
This is discussed in greater detail in chapter Missed Tasks Handling.
nnCron LITE can define local environment variables right in a crontab file. Local environment variables (i. e. variables available only to application started by nnCron) are defined with word SET. See Working with Environment Variables for a more detailed description of the subject.
In command field and in SET constructs you can use the predefined variables of nnCron LITE.
Example:
30 9 * * * %COMSPEC% /c d:\tools\my_bat.bat 0 12 * * 1-5 d:\tools\maintain.bat %DD%-%MMM%-%YYYY%.log
There also exist a special type of syntax allowing to execute any Forth word as a command; this allows to execute scripts of any desired complexity, written in Forth programming language (SP-Forth). This is discussed in greater detail in chapter nnCron LITE and Forth Programing Language.