<div class="section" id="time-dependencies"> <span id="index-0"></span> <div class="line-block"> <div class="line">Sometimes you want a <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-task"><em class="xref std std-term">task</em></a> to run at a given time, or to run every three hours,</div> <div class="line">or to run only on the first of the month, or on Mondays,...</div> <div class="line">For that ecFlow supports <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-date"><em class="xref std std-term">date</em></a> and <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-time"><em class="xref std std-term">time</em></a> <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-dependencies"><em class="xref std std-term">dependencies</em></a>.</div> </div> <div class="section" id="time"> <span id="id1"></span><h2>time<a class="headerlink" href="#time" title="Permalink to this headline">¶</a></h2> <div class="line-block"> <div class="line"><a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-time"><em class="xref std std-term">time</em></a> <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-dependencies"><em class="xref std std-term">dependencies</em></a> can be <strong>absolute</strong>, i.e. they will run at the exact time.</div> <div class="line">They can also be <strong>relative</strong>; in this case we provide the time from the moment the <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-suite"><em class="xref std std-term">suite</em></a> is begun.</div> <div class="line">Time <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-dependencies"><em class="xref std std-term">dependencies</em></a> can be repeated at regular intervals</div> </div> <div class="highlight-python"><pre>time 23:00 # at next 23:00 time 10:00 20:00 01:00 # every hour from 10am to 8pm time +00:01 # one minute after the begin suite time +00:10 01:00 00:05 # 10 to 60 minutes after begin every 5 minutes</pre> </div> </div> <div class="section" id="date-or-day"> <span id="id2"></span><h2>date or day<a class="headerlink" href="#date-or-day" title="Permalink to this headline">¶</a></h2> <div class="line-block"> <div class="line">Date <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-dependencies"><em class="xref std std-term">dependencies</em></a> can be specified using the <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-date"><em class="xref std std-term">date</em></a> or the <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-day"><em class="xref std std-term">day</em></a> keyword.</div> <div class="line">Date <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-dependencies"><em class="xref std std-term">dependencies</em></a> are always absolute, but wild cards can be used.</div> </div> <div class="highlight-python"><pre>date 31.12.2012 # the 31st of December 2012 date 01.*.* # every first of the month date *.10.* # every day in October date 1.*.2008 # every first of the month, but only in 2008 day monday # every monday</pre> </div> </div> <div class="section" id="cron"> <span id="id3"></span><h2>cron<a class="headerlink" href="#cron" title="Permalink to this headline">¶</a></h2> <p>Cron <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-dependencies"><em class="xref std std-term">dependencies</em></a> can be specified using the <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-cron"><em class="xref std std-term">cron</em></a> keyword:</p> <div class="highlight-python"><pre>cron 23:00 # every day at 23:00 cron 08:00 12:00 01:00 # every hour between 8 and 12 cron -w 0,2 # every sunday and tuesday cron -d 1,15 # every 1st and 15th of each month cron -m 1 -d 1 # every first of January</pre> </div> <p>A task can have several <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-time"><em class="xref std std-term">time</em></a> and <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-date"><em class="xref std std-term">date</em></a> <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-dependencies"><em class="xref std std-term">dependencies</em></a>. For example:</p> <div class="highlight-python"><pre>day sunday day wednesday date 01.*.* # The first of every month and year date 10.*.* # The tenth of every month and year time 01:00 time 16:00</pre> </div> <div class="line-block"> <div class="line">The <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-task"><em class="xref std std-term">task</em></a> will run on sunday’s and wednesday’s at 1am and 4pm, but only if</div> <div class="line">the day is the 1st or the 10th of the month.</div> </div> <div class="line-block"> <div class="line">Like <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-trigger"><em class="xref std std-term">trigger</em></a>‘s, <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-date"><em class="xref std std-term">date</em></a> and <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-time"><em class="xref std std-term">time</em></a> <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-dependencies"><em class="xref std std-term">dependencies</em></a> can be set for a <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-family"><em class="xref std std-term">family</em></a>.</div> <div class="line">In this case, the tasks of this family will only run according to these <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-dependencies"><em class="xref std std-term">dependencies</em></a>.</div> </div> <div class="admonition note"> <p class="first admonition-title">Note</p> <p>All time related dependencies(like <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-cron"><em class="xref std std-term">cron</em></a>, <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-time"><em class="xref std std-term">time</em></a>, <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-today"><em class="xref std std-term">today</em></a>, <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-date"><em class="xref std std-term">date</em></a> and <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-day"><em class="xref std std-term">day</em></a>) are relative to the <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-clock"><em class="xref std std-term">clock</em></a> of the <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-suite"><em class="xref std std-term">suite</em></a>.</p> <p class="last">For more information, see <a class="reference internal" href="/wiki/display/ECFLOW/Dates+and+Clocks#dates-and-clocks"><em>Dates and Clocks</em></a></p> </div> </div> <div class="section" id="text"> <h2>Text<a class="headerlink" href="#text" title="Permalink to this headline">¶</a></h2> <div class="line-block"> <div class="line">Let us modify the definition file to add a <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-family"><em class="xref std std-term">family</em></a> <strong>f2</strong>.</div> <div class="line">For brevity we have omitted the previous <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-family"><em class="xref std std-term">family</em></a> <strong>f1</strong></div> </div> <div class="highlight-python"><pre># Definition of the suite test suite test edit ECF_INCLUDE "$HOME/course" # replace '$HOME' with the path to your home directory edit ECF_HOME "$HOME/course" family f2 edit SLEEP 20 task t1 time 00:30 23:30 00:30 task t2 day sunday task t3 date 01.*.* time 12:00 task t4 time +00:02 task t5 time 00:02 endfamily endsuite</pre> </div> </div> <div class="section" id="python"> <h2>Python<a class="headerlink" href="#python" title="Permalink to this headline">¶</a></h2> <p>For brevity we have left out <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-family"><em class="xref std std-term">family</em></a> <strong>f1</strong>. In python this would be:</p> <div class="highlight-python"><div class="highlight"><pre><span class="c">#!/usr/bin/env python2.7</span> <span class="kn">import</span> <span class="nn">os</span> <span class="kn">import</span> <span class="nn">ecflow</span> <span class="k">def</span> <span class="nf">create_family_f2</span><span class="p">():</span> <span class="n">f2</span> <span class="o">=</span> <span class="n">ecflow</span><span class="o">.</span><span class="n">Family</span><span class="p">(</span><span class="s">"f2"</span><span class="p">)</span> <span class="n">f2</span><span class="o">.</span><span class="n">add_variable</span><span class="p">(</span><span class="s">"SLEEP"</span><span class="p">,</span> <span class="mi">20</span><span class="p">)</span> <span class="n">f2</span><span class="o">.</span><span class="n">add_task</span><span class="p">(</span><span class="s">"t1"</span><span class="p">)</span><span class="o">.</span><span class="n">add_time</span><span class="p">(</span> <span class="s">"00:30 23:30 00:30"</span> <span class="p">)</span> <span class="c"># start(hh:mm) end(hh:mm) increment(hh:mm)</span> <span class="n">f2</span><span class="o">.</span><span class="n">add_task</span><span class="p">(</span><span class="s">"t2"</span><span class="p">)</span><span class="o">.</span><span class="n">add_day</span><span class="p">(</span> <span class="s">"sunday"</span> <span class="p">)</span> <span class="c"># for add_date(): day,month,year; here 0 means every month, and every year</span> <span class="n">t3</span> <span class="o">=</span> <span class="n">f2</span><span class="o">.</span><span class="n">add_task</span><span class="p">(</span><span class="s">"t3"</span><span class="p">)</span> <span class="n">t3</span><span class="o">.</span><span class="n">add_date</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="c"># day month year, first of every month or every year</span> <span class="n">t3</span><span class="o">.</span><span class="n">add_time</span><span class="p">(</span> <span class="mi">12</span><span class="p">,</span> <span class="mi">0</span> <span class="p">)</span> <span class="c"># hour, minutes at 12 o'clock</span> <span class="n">f2</span><span class="o">.</span><span class="n">add_task</span><span class="p">(</span><span class="s">"t4"</span><span class="p">)</span><span class="o">.</span><span class="n">add_time</span><span class="p">(</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="bp">True</span> <span class="p">)</span> <span class="c"># hour, minutes, relative to suite start</span> <span class="c"># 2 minutes after family f2 start</span> <span class="n">f2</span><span class="o">.</span><span class="n">add_task</span><span class="p">(</span><span class="s">"t5"</span><span class="p">)</span><span class="o">.</span><span class="n">add_time</span><span class="p">(</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span> <span class="p">)</span> <span class="c"># hour, minutes suite site</span> <span class="c"># 2 minutes past midnight</span> <span class="k">return</span> <span class="n">f2</span> <span class="k">print</span> <span class="s">"Creating suite definition"</span> <span class="n">defs</span> <span class="o">=</span> <span class="n">ecflow</span><span class="o">.</span><span class="n">Defs</span><span class="p">()</span> <span class="n">suite</span> <span class="o">=</span> <span class="n">defs</span><span class="o">.</span><span class="n">add_suite</span><span class="p">(</span><span class="s">"test"</span><span class="p">)</span> <span class="n">suite</span><span class="o">.</span><span class="n">add_variable</span><span class="p">(</span><span class="s">"ECF_INCLUDE"</span><span class="p">,</span> <span class="n">os</span><span class="o">.</span><span class="n">getenv</span><span class="p">(</span><span class="s">"HOME"</span><span class="p">)</span> <span class="o">+</span> <span class="s">"/course"</span><span class="p">)</span> <span class="n">suite</span><span class="o">.</span><span class="n">add_variable</span><span class="p">(</span><span class="s">"ECF_HOME"</span><span class="p">,</span> <span class="n">os</span><span class="o">.</span><span class="n">getenv</span><span class="p">(</span><span class="s">"HOME"</span><span class="p">)</span> <span class="o">+</span> <span class="s">"/course"</span><span class="p">)</span> <span class="n">suite</span><span class="o">.</span><span class="n">add_family</span><span class="p">(</span> <span class="n">create_family_f1</span><span class="p">()</span> <span class="p">)</span> <span class="n">suite</span><span class="o">.</span><span class="n">add_family</span><span class="p">(</span> <span class="n">create_family_f2</span><span class="p">()</span> <span class="p">)</span> <span class="k">print</span> <span class="n">defs</span> <span class="k">print</span> <span class="s">"Checking job creation: .ecf -> .job0"</span> <span class="k">print</span> <span class="n">defs</span><span class="o">.</span><span class="n">check_job_creation</span><span class="p">()</span> <span class="k">print</span> <span class="s">"Checking trigger expressions"</span> <span class="k">print</span> <span class="n">defs</span><span class="o">.</span><span class="n">check</span><span class="p">()</span> <span class="k">print</span> <span class="s">"Saving definition to file 'test.def'"</span> <span class="n">defs</span><span class="o">.</span><span class="n">save_as_defs</span><span class="p">(</span><span class="s">"test.def"</span><span class="p">)</span> </pre></div> </div> <p><strong>What to do:</strong></p> <ol class="arabic simple"> <li>Make the changes to the <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-suite-definition"><em class="xref std std-term">suite definition</em></a> file</li> <li>Create all the necessary <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-ecf-script"><em class="xref std std-term">ecf script</em></a>‘s by copying the one from <strong>/test/f1/t7</strong></li> <li>Load and begin the suite</li> <li>Once you start the suite some of the task will be immediately <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-complete"><em class="xref std std-term">complete</em></a>. Why?</li> <li><a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-ecflowview"><em class="xref std std-term">ecflowview</em></a> has a special window to explain why a task is <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-queued"><em class="xref std std-term">queued</em></a>. Select a <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-queued"><em class="xref std std-term">queued</em></a> task and press the <img alt="why" src="../../../_images/why.jpg" /> icon</li> </ol> </div> </div> |