OPNsense Forum

English Forums => Development and Code Review => Topic started by: Stephan on October 16, 2017, 12:41:51 pm

Title: [SOLVED]adding custom cron job?
Post by: Stephan on October 16, 2017, 12:41:51 pm
Hi there,

I tried to add a custom cron job by adding a conf file to /usr/local/opnsense/service/conf/actions.d/ and tested it successfully with configctl.

Now I wonder whats the magic that this command shows up in the command list in the web interface (settings/cron)?

Thanx,

Stephan

[EDIT]: After restarting all services it worked - the question remains: which service reloads the item list?
a quick guide how to create individual cron jobs can be found here https://forum.opnsense.org/index.php?topic=2263.0 (https://forum.opnsense.org/index.php?topic=2263.0)
Title: Re: adding custom cron job?
Post by: mimugmail on October 16, 2017, 01:47:48 pm
If I remember correctly the file needs a description to do the magic :)
Title: Re: adding custom cron job?
Post by: Stephan on October 16, 2017, 02:03:52 pm
Hmm, yes - that's what I thought too...
This is the output from configctl:
Code: [Select]
configctl configd actions list|grep squidan
squidanalyzer update [ Update squidanalyzer data ]

and that's the config file:

Code: [Select]
[update]
command:/usr/local/bin/squid-analyzer
parameter:
type:script
message:Updating squidanalyzer data
description:Update squidanalyzer data

They discussed it here https://forum.opnsense.org/index.php?topic=1936.0 (https://forum.opnsense.org/index.php?topic=1936.0) for a module - and iosense wrote somth about a 'typo' though I can't see anything wrong in his code above...
Title: Re: adding custom cron job?
Post by: Stephan on October 16, 2017, 02:23:23 pm
 meanwhile found this https://forum.opnsense.org/index.php?topic=2263.0 (https://forum.opnsense.org/index.php?topic=2263.0) which is exactly what I did...

also did a
Code: [Select]
/usr/local/etc/rc.restart_webgui
Title: Re: adding custom cron job?
Post by: Stephan on October 16, 2017, 02:50:19 pm
ok - sorry for any inconveniences  8)

after a restart of the service it showed up in the list!  ;)

Cheers,

Stephan
Title: Re: [SOLVED]adding custom cron job?
Post by: franco on October 16, 2017, 11:47:47 pm
May be missing:

# service configd restart


Cheers,
Franco
Title: Re: [SOLVED]adding custom cron job?
Post by: Stephan on October 17, 2017, 06:43:25 pm
May be missing:

# service configd restart


Cheers,
Franco
hmm - is there a difference between
Code: [Select]
configctl configd restart and this?
Title: Re: [SOLVED]adding custom cron job?
Post by: franco on October 17, 2017, 06:48:42 pm
Not really. The former uses the FreeBSD facility, the latter lets the daemon do the restart itself.
Title: Re: [SOLVED]adding custom cron job?
Post by: thefunkygibbon on March 08, 2022, 03:59:40 pm
i have edited one of the "action...." files and added a command to run a script.  which was working.  but this file just got overwritten by a opnsense system update (just a minor one).   how can we go about making these changes survive such an update?
Title: Re: [SOLVED]adding custom cron job?
Post by: franco on March 10, 2022, 01:51:02 pm
Do not edit existing files...they are operated by firmware updates... create your own file.


Cheers,
Franco