Very strange cron behaviour

Started by Cadish, February 19, 2021, 09:04:50 AM

Previous topic - Next topic
Hi all,

I've setup a cron job to restart my WAN interface when my connection drops and reboot if this doesn't help, according to the post of marjohn56.

I've setup a cron job in the GUI as described (see attachment).

Now comes the strange thing: after a reboot, the cron job doesn't start, unless I hit "Apply" on the cron page again. So after each reboot, I must hit the "Apply" button (even without changing anything) before the cron job starts successfully every 5 minutes.

Any clue what can be wrong?

Thanks
Cadish

February 24, 2021, 08:58:17 AM #1 Last Edit: February 24, 2021, 09:12:37 AM by Cadish
To add to the strange behaviour: sometimes the cron is loaded correctly after a reboot, sometimes not...

And this goes for all cron jobs, not only the one above... no cron jobs run until I hit "Apply" on the cron page.

Am I really the only one with this problem? What's the best approach to get this issue fixed? Really don't know what to look for, as I have no errors or whatsoever... (that I know of)

Cadish

You could try moving the script into one of the folders mentioned in this link:

https://docs.opnsense.org/development/backend/autorun.html

Depending on which folder you put it in, the script will run under different conditions (e.g. the 'monitor' folder for "scripts handling gateway monitoring events").  You could then update the .conf file accordingly with the path.

Thanks for your reply jonf!

I will try to move my file somewhere else. But I notice that it's also affecting cron jobs not created by me, like "ids update" by Suricata. It doesn't run at 23h45, unless cron is restarted manually. So I guess something bigger than my own script is blocking cron to run after a reboot...

This is my /var/cron/tabs/nobody file:

# DO NOT EDIT THIS FILE -- OPNsense auto-generated file
#
# User-defined crontab files can be loaded via /etc/cron.d
# or /usr/local/etc/cron.d and follow the same format as
# /etc/crontab, see the crontab(5) manual page.
SHELL=/bin/sh
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
#minute hour    mday    month   wday    command
# Origin/Description: IDS/ids rule updates
45      23      *       *       *       /usr/local/sbin/configctl ids update
# Origin/Description: cron/Check connection and reboot if necessary
*/5     *       *       *       *       /usr/local/sbin/configctl ping_check load

I removed some old url tables from the firewall aliases (which were redirecting to 404's), and the cron jobs seems to load fine now. Don't know if this is possible or just coincidence?

Will reboot a couple of times in the next days, but hopefully my problem is solved now...

The issue seems to be solved by removing unreachable URL tables. Rebooted a few times and the cron jobs run just fine now.

It's quite strange to me that these could influence the correct starting of the cron jobs.

Regards,
Cadish