You should add a permanent backend job as per https://docs.opnsense.org/development/backend/configd.html
[trim]command:zpool trimparameters: %stype:script_outputmessage: Run ZFS trim on specified pooldescription: zpool trim [zpool][scrub]command:zpool scrubparameters: %stype:script_outputmessage: Run ZFS scrub on specified pooldescription: zpool scrub [zpool]
PS: https://forum.opnsense.org/index.php?topic=30993.0