Create a cron job

Started by FredFresh, November 06, 2025, 09:02:06 PM

Previous topic - Next topic
Hi , I want to create a job following this https://docs.opnsense.org/development/backend/configd.html
that periodically perform a trace-route from internal gateway A to internal ip B

can you help me understand how to fill the .conf file for this ?

Thanks

It's rather simple -- suppose we have a file actions_foobar.conf:

[NameOfCommand]
command:/the/command/to/execute
parameters:
type:script
message:insert what it does here for logging
description:Only with this it will show in the cron GUI

The command should execute as:

# configctl foobar NameOfCommand

Reminder: configd needs a restart to register new commands to be able to call them.


Cheers,
Franco

Hi Franco, yes I understad the guide (I already used it) but I do not know how to properly populate the .conf file with the command that perform the traceroute from A to B.

Thanks

Is A an address on your OPNsense?
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

A is a gateway and B is an IP.

Maybe I found a suitable possible example:

traceroute -g 10.3.0.5 128.182.0.0

would this work considering 10.3.0.5 the gateway and the 128.128.0.0 the ip?

thanks

To trace from A to B the traceroute command MUST run on system A.
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

yes sorry, i just pasted the example from freebsd page

the command would be something like traceroute -g 192.168.2.1 172.16.7.1 (where both these addresses are from internal subnets)

And 192.168.2.1 is an interface on your OPNsense?
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)


Then you can just run

traceroute -s 192.168.2.1 172.16.7.1
Lose source routing (-g option) is a mechanism from the bronze age of the Internet and not used/followed by modern systems, anymore.
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

I create here /usr/local/opnsense/service/conf/actions.d  the file actions_VPN_GW_CZ_routes.conf

inside there is this

[trace]
command:traceroute -s 192.168.2.1 10.2.2.1
parameters:
type:script
message:automatic traceroute to VPN CZ gateway
description:automatic traceroute to VPN CZ gateway

I reset the service using
service configd restart

I can see the new line in the CRON drop down menu

But if I try to run
configctl VPN_GW_CZ_routes trace

It returns
Action not allowed or missing

What I am doing wrong?
thanks