Crontab is not keeping job related to user entries

Started by PJ79, November 21, 2022, 07:28:35 AM

Previous topic - Next topic
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.
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

...hmm... why isn't there any CLI in the GUI (aynmore)? ;-)
kind regards
chemlud
____
"The price of reliability is the pursuit of the utmost simplicity."
C.A.R. Hoare

felix eichhorns premium katzenfutter mit der extraportion energie

A router is not a switch - A router is not a switch - A router is not a switch - A rou....

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.
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

November 21, 2022, 10:01:30 AM #6 Last Edit: November 21, 2022, 10:32:03 AM by franco
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.  :)
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

Seems like franco comment helped me :)
Thank you, guys.

November 23, 2022, 10:11:41 PM #9 Last Edit: November 23, 2022, 10:43:20 PM by abulafia
Quote from: franco on November 21, 2022, 08:19:16 AM
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