Local command task

A local command task will execute a command directly on the server where CTFreak is installed.

For those who need to schedule high-frequency command execution, local command task may be more suitable than command task, as it avoids the constraints of an SSH connection and the network.

Given that local commands have write access to CTFreak configuration files, only an administrator can create this type of task.

Here is an example:

  • echo "Hello!" (when CTFreak is installed on a Unix server)

  • Write-Host 'Hello!' (when CTFreak is installed on a Windows server)

Prerequisites for executing a local command on a Windows host server

Use Unicode UTF-8 for worldwide language support

On the host server, go to:

Settings > Time & Language > Language & region > Administrative language settings > Administrative tab > Change system locale button

Enable “Beta:Use Unicode UTF-8 for worldwide language support.”

Install Powershell >= 7.2

CTFreak requires a recent version of powershell to correctly retrieve log content (especially error outputs).

Task characteristics

In addition to the common task characteristics, here are those specific to local command tasks.

Use shell

By default, a shell (bash on UNIX, powershell >=7.2 on Windows) is launched at each execution to interpret a command line.

If the shell is disabled, the command line is replaced by the program to be launched and its arguments.

Log output

You can specify whether you wish to keep execution logs:

  • Systematically
  • Only in the event of failure or abort
  • Never

Using project constants

Project constants can be used as environment variables prefixed with CPC_ (for CTFreak Project Constant).

Here’s an example using a project constant named NUMBER_OF_RETENTION_DAYS in a bash command line:

clean-backup --retention-period $CPC_NUMBER_OF_RETENTION_DAYS

If you later decide to increase the retention period of your backups, you’ll only need to modify the constant value to affect all cleanup commands referring to it.

Using task parameters

Like project constants, task parameters can be used as environment variables prefixed with CTP_ (for CTFreak Task Parameter).

Here’s an example using a text task parameter named FIRST_NAME in a bash command line:

echo "Hello $CTP_FIRST_NAME !"

Task parameters values are converted to text format when assigned to an environment variable.

The following conversion rules are applied according to parameter type:

  • Checkbox → Checked: true, Unchecked: false
  • Date → Formatting with the YYYY-MM-DD pattern
  • Selector, Integer and Text → No specific formatting