Init/Shutdown Scripts

How to add commands or scripts that automatically run when TrueNAS starts or begins to shut down.

  2 minute read

TrueNAS provides the ability to schedule commands or scripts to run at system startup or shutdown.

Go to Tasks > Init/Shutdown Scripts and click ADD.

Init/Shutdown Options

DescriptionstringWrite any comments about this task.
Typedrop-down menuSelect Command for an executable or Script for an executable script.
Command or ScriptstringWhen Command is selected, enter the command with any options. When Script is selected, click   (Browse) to select the script from an existing pool.
Whendrop-down menuSelect when the Command or Script runs: Pre Init: early in the boot process, after mounting filesystems and starting networking. Post Init: at the end of the boot process, before TrueNAS services start. Shutdown: during the system power off process.
EnabledcheckboxEnable this task. Unset to disable the task without deleting it.
TimeoutintegerAutomatically stop the script or command after the specified number of seconds.

Scheduled commands must be in the default path. The full path to the command can also be included in the entry. The path can be tested with which {commandname} in the Shell. When available, the path to the command is shown:

[root@freenas ~]# which ls

When scheduling a script, test the script first to verify it is executable and achieves the desired results.

Init/shutdown scripts are run with sh.

All saved Init/Shutdown tasks are shown in Tasks > Init/Shutdown Scripts. Click   (Options) for a task to Edit or Delete that task.

Last modified September 25, 2020: DOCS-986: Review Init/Shutdown content (43a352ba)