OPNsense Forum

English Forums => General Discussion => Topic started by: tortellini on April 12, 2016, 02:29:29 am

Title: crontab resetting after reboot
Post by: tortellini on April 12, 2016, 02:29:29 am
Hi, every time the server reboots; the crontab resets. How can we save cronjobs during reboots?
Using 16.1.9. Not sure if always an issue; but, using for past few months.
Title: Re: crontab resetting after reboot
Post by: franco on April 12, 2016, 09:01:48 am
We're planning to open up the cron GUI for 16.7, but have no ETA at the moment other than "ready in July". The reset behaviour is intended.
Title: Re: crontab resetting after reboot
Post by: sstreiner on July 31, 2016, 07:08:31 pm
Hi guys! I'd also like to have some cronjobs :)
Using 16.7 gives me a cronjob ui, but unfortunately there is no "custom command" option.
I can only use predefined commands.

Bug? Works as desired? Workarounds?

Cheers,
Sam
Title: Re: crontab resetting after reboot
Post by: AdSchellevis on July 31, 2016, 07:40:20 pm
Hi Sam,

Works as intended.
You need to define configd commands first, which can automatically be registered for use in cron.

See https://docs.opnsense.org/development/backend/configd.html?highlight=configd (https://docs.opnsense.org/development/backend/configd.html?highlight=configd) for information how to register new commands.

Don't forget to add a description, only commands with a description are shown by cron (for example see this commit which exposes the alias update to cron https://github.com/opnsense/core/commit/c0a724a922f1393902f64929a9b90a5e443783ec#diff-e7a381bb88c962fd620afd853b662f52 (https://github.com/opnsense/core/commit/c0a724a922f1393902f64929a9b90a5e443783ec#diff-e7a381bb88c962fd620afd853b662f52)).

Best regards,

Ad
Title: Re: crontab resetting after reboot
Post by: franco on August 01, 2016, 09:29:34 am
Ok, this is a bit tricky...

/var/cron/tabs/root -- autogenerated by OPNsense, harbours the old *sense cron jobs
/var/cron/tabs/nobody -- autogenerated by OPNsense, harbours the privilege-separated cron jobs

The Cron GUI updates the latter, so simply running custom commands will likely not work because they'd require more privileges.

We, however, do not touch /etc/crontab anymore. The only problem is that it gets rewritten on FreeBSD userland updates to keep its commands in sync with the rest of the system.

The long-term solution is porting all remaining jobs from /var/cron/tabs/root to /var/cron/tabs/nobody, freeing the former for manual usage.

The short or mid-term solutions are talking about what kind of jobs you think about running and seeing if we (a) already have them under the hood and only need to plant them in the GUI or (b) provide the commands via the backend system.


Cheers,
Franco
Title: Re: crontab resetting after reboot
Post by: interkrome on August 11, 2016, 08:57:06 am
Seems like almost identical with my case :

https://forum.opnsense.org/index.php?topic=3511.0
Title: Re: crontab resetting after reboot
Post by: tillsense on August 18, 2016, 07:17:29 pm
read too late. (Update 16.7.2) I have added under the roadmap ideas.
https://forum.opnsense.org/index.php?topic=3516.0