Adding a cron

The ecFlow server records all commands sent to it, in a log file (<host>.<port>.ecf.log) This log file will grow over time to a considerable size. This section will create a task, whose job is to periodically back up and clear this log file.

This can be done with a cron attribute introduced previously. A cron will run indefinitely i.e. once it has completed it will automatically requeue itself.

More examples of how to add a cron, using the Python API, can be found at Adding Time Dependencies.

Task Script

Create a new task script named clear_log.ecf.

Listing 43 $HOME/course/test/house_keeping/clear_log.ecf
%include <head.h>

# copy the log file to the ECF_HOME/log directory
cp %ECF_LOG% %ECF_HOME%/log/.

# clear the log file
ecflow_client  --log=clear

%include <tail.h>

Update Suite Definition

Create a new family named house_keeping and add the task clear_log to it, that will run every Sunday at 10:30pm.

suite test
    edit ECF_INCLUDE "{{HOME}}/course" # replace '{{HOME}}' appropriately
    edit ECF_HOME    "$HOME/course"

    [... previous families omitted for brevity ..]

    family house_keeping
        task clear_log
        cron -w 0 22:30  # run every Sunday at 10:30pm
    endfamily
endsuite

What to do:

  1. Update the suite definition to include the new family and task.

  2. Create the new task script clear_log.ecf in the appropriate directory.

  3. Replace the suite, using:

    ecflow_client --suspend /test
    ecflow_client --replace /test test.def
    
  4. Use ecflow_ui to inspect why a task is queued, by selecting a queued task and clicking on the Why tab.

  5. Manually run the task, and examine the log file on disk.