OPNsense Forum

Archive => 19.7 Legacy Series => Topic started by: phoenix on August 14, 2019, 08:01:12 pm

Title: [Resolved] Problem running cron job
Post by: phoenix on August 14, 2019, 08:01:12 pm
I currently have the 19.7.2 release installed and it seems getting a cron job to run has changed since I last did this. :(

Because of a problem with my 'box' that connects me to the internet where I occasionally lose all outside contact I need to reboot this at that point to regain my connection.

First of all I went to the UI and System/Settings/cron and tried to add a new job there only to find a pre-existing list of command that couldn't be modified or new ones added. Checked the documentation here https://docs.opnsense.org/manual/settingsmenu.html?highlight=cron#cron  (https://docs.opnsense.org/manual/settingsmenu.html?highlight=cron#cron) which basically confirmed I was looking at the correct screen.

It was only when I found this site http://kb.unixservertech.com/other/networking/opnsense/cron-jobs (http://kb.unixservertech.com/other/networking/opnsense/cron-jobs) that I discovered configd is now used.

I have a script that checks my connection to the internet by basically sending a ping to several sites and if it fail it will reboot my 'box' to restore the connection. I duly recreated a new config file for configd, restarted the service and tested that it ran my script correctly, it did and entered several entries in the log file. I'd also created a new cron job using my config file a the 'job' and set it to be run every five minutes. After that, nothing! The script does not run and no further entries appear in the log file.
I've currently placed my script in "/etc/rc.conf.d/scripts" (is there somewhere more appropriate?) and the config file contains this:

Code: [Select]
[reload]
command:/etc/rc.conf.d/scripts/freebox-check
parameter: %s
type:script
message:Check Freebox Internet Connection
description:Freebox Connectivity Check

Is there something obvious I might have missed or anything else that needs to be checked to get this cron job working?

Sorry about the long post.

Title: Re: Problem running cron job
Post by: phoenix on August 16, 2019, 06:47:43 pm
Just for clarification, this is just a bash script I'm trying to run via cron. It does work when manually run and it also runs when OPNsense is rebooted but it only runs once and never on the set schedule of 5 minutes (that's just for testing) after it's first run.

Is there any way to debug why a cron job isn't being run on it's set schedule? Does anyone else see this problem?
Title: Re: Problem running cron job
Post by: phoenix on August 17, 2019, 07:47:02 am
Strangely, this seems to now be working. The only thing I did was to change the schedule to every 30 minutes, this morning I checked and the jobs have been running overnight.