Get a Quote     (408) 943-4100               TrueNAS Discord      VendOp_Icon_15x15px   Commercial Support Toggle between Light and Dark mode

Managing Cron Jobs

  2 minute read.

Last Modified 2022-12-13 12:31 -0500

Cron jobs allow users to configure jobs that run specific commands or scripts on a regular schedule using cron(8). Cron Jobs help users run repetitive tasks.

Advanced settings have reasonable defaults in place. A warning message displays for some settings advising of the dangers making changes. Changing advanced settings can be dangerous when done incorrectly. Use caution before saving changes.

ChangingAdvancedSettingsWarning

Make sure you are comfortable with ZFS, Linux, and system configuration backup and restoration before making any changes.

The Cron Jobs widget on the System > Advanced screen displays No Cron Jobs configured until you add a cron job, and then it displays information on cron job(s) configured on the system.

AdvancedSettingsCronJobWidget

Click Add to open the Add Cron Job configuration screen to create a new cron job, or if you want to modify an existing job, click anywhere on the item to open the Edit Cron Jobs configuration screen populated with the settings for that cron job. The Add Cron Job and Edit Cron Job configuration screens display the same settings.

AddCronJobsScreen

Enter a description for the cron job.

Next, enter the full path to the command or script to run in Command. For example, a command string to create a list of users on the system and write that list to a file enter cat /etc/passwd > users_$(date +%F).txt.

Select a user account to run the command from the Run As User dropdown list. The user must have permissions allowing them to run the command or script.

Select a schedule preset or choose Custom to open the advanced scheduler. Note that an in-progress cron task postpones any later scheduled instance of the same task until the running task is complete.

If you want to hide standard output (stdout) from the command, select Hide Standard Output. If left cleared, TrueNAS emails any standard output to the user account cron that ran the command.

To hide error output (stderr) from the command, select Hide Standard Error. If left cleared, TrueNAS emails any error output to the user account cron that ran the command.

Select Enabled to enable this cron job. If you leave this checkbox cleared it disables the cron job without deleting it.

Click Save.

Related Content