other:networking:opnsense:cron-jobs
Differences
This shows you the differences between two versions of the page.
| other:networking:opnsense:cron-jobs [2020/01/11 19:17] – created - external edit 127.0.0.1 | other:networking:opnsense:cron-jobs [2026/07/17 01:51] (current) – rodolico | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== opnSense Cron Jobs ====== | ====== opnSense Cron Jobs ====== | ||
| + | |||
| + | ===== Overview ===== | ||
| Basically, it uses [[http:// | Basically, it uses [[http:// | ||
| - | < | + | < |
| - | cd / | + | |
| - | </ | + | |
| Create a file with the name // | Create a file with the name // | ||
| - | Example of a file named actions_updatedns.conf: | + | After creating the file, you will need to restart configd, then test your configuration |
| + | <code bash> | ||
| + | service configd restart | ||
| + | configctl COMMANDNAME start # or reload, or whatever | ||
| + | </ | ||
| + | **COMMANDNAME** is the command you created. The filename, without the preceeding // | ||
| + | |||
| + | Once this is done, the string after message (or description, | ||
| + | |||
| + | You can create multiple actions (stop, | ||
| + | |||
| + | The log files are stored in / | ||
| + | |||
| + | ===== Examples ===== | ||
| + | |||
| + | ==== updatedns ==== | ||
| + | This will execute the script / | ||
| <file name=actions_updatedns.conf> | <file name=actions_updatedns.conf> | ||
| [reload] | [reload] | ||
| Line 18: | Line 34: | ||
| </ | </ | ||
| - | Now that you have added a new config, you need to reload configd so it will read it: | + | Note that this uses the **reload** parameter. |
| + | |||
| + | Now that you have added a new config, you need to reload configd so it will read it, then test it (we are passing **reload** to it since that is the action we are using) | ||
| < | < | ||
| service configd restart | service configd restart | ||
| - | </ | ||
| - | And, test that you did everything right | ||
| - | < | ||
| configctl updatedns reload | configctl updatedns reload | ||
| </ | </ | ||
| - | the script / | ||
| - | Once this is done, the string after message (or description, | + | ==== Starting suricata if it dies ==== |
| - | The log files are stored in /var/log/configd.log | + | I ran into a problem where suricata would randomly die on rule rule reload, so I set up a cron job to see if it was running and, if not, start it up |
| + | |||
| + | First, I created the file /usr/local/opnsense/ | ||
| + | <file name=actions_suricata_watchdog.conf> | ||
| + | [start] | ||
| + | command:/ | ||
| + | type: | ||
| + | message: | ||
| + | description: | ||
| + | </ | ||
| + | |||
| + | Reloaded | ||
| + | <code bash> | ||
| + | service configd restart | ||
| + | configctl suricata_watchdog start | ||
| + | </ | ||
| + | |||
| + | Then, I went to the opnSense GUI and made a new entry in System | Settings | Cron to run at 14 minutes after the hour, every hour (I can lose a little bit of monitoring, and did not want it running every minute). | ||
| + | |||
| + | Note that I built this totally inside of the config file; no external files to access and run. I just told it to use the command: | ||
| + | <code bash> | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | This is basic shell magic. By calling service suricata status, I'll check the status of suricata. I don't care about the output, so I send STDOUT and STDERR to /dev/null. What I want is the return status, which is false if the service is not running. In that case, the || (OR) will execute the other command, which will start suricata back up. | ||
| ==== Bibliography ==== | ==== Bibliography ==== | ||
other/networking/opnsense/cron-jobs.txt · Last modified: by rodolico
