<metaname="description"content="Event Scheduler The ENiGMA½ scheduler allows system operators to configure arbitrary events that can can fire based on date and/or time, or by watching for changes in a file. Events can kick off internal handlers, custom modules, or binaries & scripts."/>
<metaproperty="og:description"content="Event Scheduler The ENiGMA½ scheduler allows system operators to configure arbitrary events that can can fire based on date and/or time, or by watching for changes in a file. Events can kick off internal handlers, custom modules, or binaries & scripts."/>
{"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"/enigma-bbs/assets/images/enigma-logo.png"}},"description":"Event Scheduler The ENiGMA½ scheduler allows system operators to configure arbitrary events that can can fire based on date and/or time, or by watching for changes in a file. Events can kick off internal handlers, custom modules, or binaries & scripts.","url":"/enigma-bbs/configuration/event-scheduler.html","@type":"BlogPosting","headline":"Event Scheduler","dateModified":"2022-06-12T18:56:22+00:00","datePublished":"2022-06-12T18:56:22+00:00","mainEntityOfPage":{"@type":"WebPage","@id":"/enigma-bbs/configuration/event-scheduler.html"},"@context":"https://schema.org"}</script>
<aclass="btn"style="float: right;margin-left: 20px"href="/enigma-bbs/configuration/acs.html">Access Condition System (ACS) »</a>
<brclear="both">
</div>
<divclass="page">
<h1class="page-title">Event Scheduler</h1>
<h2id="event-scheduler">Event Scheduler</h2>
<p>The ENiGMA½ scheduler allows system operators to configure arbitrary events that can can fire based on date and/or time, or by watching for changes in a file. Events can kick off internal handlers, custom modules, or binaries & scripts.</p>
<h2id="scheduling-events">Scheduling Events</h2>
<p>To create a scheduled event, create a new configuration block in <codeclass="language-plaintext highlighter-rouge">config.hjson</code> under <codeclass="language-plaintext highlighter-rouge">eventScheduler.events</code>.</p>
<td>A <ahref="https://bunkat.github.io/later/parsers.html#text">Later style</a> parsable schedule string such as <codeclass="language-plaintext highlighter-rouge">at 4:00 am</code>, or <codeclass="language-plaintext highlighter-rouge">every 24 hours</code>. Can also be (or contain) an <codeclass="language-plaintext highlighter-rouge">@watch</code> clause. See <strong>Schedules</strong> below for details.</td>
<td>Action to perform when the schedule is triggered. May be an <codeclass="language-plaintext highlighter-rouge">@method</code> or <codeclass="language-plaintext highlighter-rouge">@execute</code> spec. See <strong>Actions</strong> below.</td>
<p>An <codeclass="language-plaintext highlighter-rouge">@watch</code> clause monitors a specified file for changes and takes the following form: <codeclass="language-plaintext highlighter-rouge">@watch:<path></code> where <codeclass="language-plaintext highlighter-rouge"><path></code> is a fully qualified path.</p>
<p><imgclass="emoji"title=":bulb:"alt=":bulb:"src="https://github.githubassets.com/images/icons/emoji/unicode/1f4a1.png"height="20"width="20"> If you would like to have a schedule <strong>and</strong> watch a file for changes, place the <codeclass="language-plaintext highlighter-rouge">@watch</code> clause second and separated with the word <codeclass="language-plaintext highlighter-rouge">or</code>. For example: <codeclass="language-plaintext highlighter-rouge">every 24 hours or @watch:/path/to/somefile.txt</code>.</p>
<h3id="actions">Actions</h3>
<p>Events can kick off actions by calling a method (function) provided by the system or custom module in addition to executing arbritary binaries or scripts.</p>
<h4id="methods">Methods</h4>
<p>An action with a <codeclass="language-plaintext highlighter-rouge">@method</code> can take the following forms:</p>
<ul>
<li>
<codeclass="language-plaintext highlighter-rouge">@method:/full/path/to/module.js:methodName</code>: Executes <codeclass="language-plaintext highlighter-rouge">methodName</code> at <codeclass="language-plaintext highlighter-rouge">/full/path/to/module.js</code>.</li>
<li>
<codeclass="language-plaintext highlighter-rouge">@method:rel/path/to/module.js:methodName</code>: Executes <codeclass="language-plaintext highlighter-rouge">methodName</code> using the <em>relative</em> path <codeclass="language-plaintext highlighter-rouge">rel/path/to/module.js</code>. Paths for <codeclass="language-plaintext highlighter-rouge">@method</code> are relative to the ENiGMA½ installation directory.</li>
</ul>
<p>Methods are passed any supplied <codeclass="language-plaintext highlighter-rouge">args</code> in the order they are provided.</p>
<h5id="method-signature">Method Signature</h5>
<p>To create your own method, simply <codeclass="language-plaintext highlighter-rouge">export</code> a method with the following signature: <codeclass="language-plaintext highlighter-rouge">(args, callback)</code>. Methods are executed asynchronously.</p>
<p>When using the <codeclass="language-plaintext highlighter-rouge">@execute</code> action, a binary or script can be executed. A full path or just the binary name is acceptable. If using the form without a path, the binary much be in ENiGMA½’s <codeclass="language-plaintext highlighter-rouge">PATH</code>.</p>