OPNsense Forum
Archive => 22.7 Legacy Series => Topic started by: PJ79 on November 21, 2022, 07:28:35 am
-
Hi Guys
First of all welcome all of You!
Maybe someone faced the same issue as me.
There are logs /var/log/filter which I need to clean up every week due to limited space assigned to Opnsense
I'm running two routers ( Master and Slave)
OPNsense 22.7.4-amd64
FreeBSD 13.1-RELEASE-p2
OpenSSL 1.1.1q 5 Jul 2022
I have created a simple bash script which is cleaning logs from /var/log/filter. This script is working in 100% as manual execution seems to result in what I want.
The issue is with crontrab where I have added an entry to start the script ( crontab -e)
0 1 * * * /root/bin/filter_bkp.sh
Then of course entry is saved and looks ok for some time.
Unfortunately, after around a week, this entry is removed ( no user action) and of course, logs are not removed.
Any thoughts
Br, Pawel
-
You should add a permanent backend job as per https://docs.opnsense.org/development/backend/configd.html
Also add a "description" to be able to select it from cron GUI and you can do this without it disappearing later on.
Cheers,
Franco
-
@franco Why doesn't the UI permit the creation of arbitrary cron jobs? I always wondered. I mean, just enter the 5 frequency fields, the user, and the command line - piece of cake. So it can't be a complexity issue.
-
...hmm... why isn't there any CLI in the GUI (aynmore)? ;-)
-
The GUI is not suitable for registering backend scripts as we do not want to store custom scripting in the config.xml. This is what the plugin system is for.
Cheers,
Franco
-
I do not want to register a backend script. Just run a single arbitrary command. I question the entire need for "backend scripts". This could work just like tuneables. There I can set whatever I deem necessary instead of choosing from a predefined list. See the cron job interface of TrueNAS for comparison.
-
This is a privilege escalation issue so we will not add arbitrary commands (or scripts).
Cheers,
Franco
-
Understood. We do have individual admin users, but all of them with full access. :)
-
Seems like franco comment helped me :)
Thank you, guys.
-
You should add a permanent backend job as per https://docs.opnsense.org/development/backend/configd.html
Great - thank you for the pointer (and apologies for not RTFM).
Here is a very simple action for ZFS scrub and ZFS trim:
[trim]
command:zpool trim
parameters: %s
type:script_output
message: Run ZFS trim on specified pool
description: zpool trim [zpool]
[scrub]
command:zpool scrub
parameters: %s
type:script_output
message: Run ZFS scrub on specified pool
description: zpool scrub [zpool]
Is it possible to permanently save a script like zrep, zrepl, znapzend or syncoid/sanoid to the OPNsense system to enable periodic snapshots (and automatic pruning thereof)?
Or would it be possible to use and persistently configure the FreeBSD periodic.conf system?
-
There was a thread recently and periodic.conf (or better periodic.conf.local) can be used at will, but needs to be edited from the shell.
You can also use your backend cron jobs this way...
# configctl zfs trim zpool
(given the actions file is actions_zfs.conf)
Cheers,
Franco
-
PS: https://forum.opnsense.org/index.php?topic=30993.0
-
PS: https://forum.opnsense.org/index.php?topic=30993.0
Thanks!