In this clip,
we're going to discuss the cron tool and how it can be used to automate tasks.
Before we automate anything, let's quickly cover what cron is.
Cron is a task scheduler for Unix and Linux systems.
It allows you to specify particular days and times for commands to run.
You configure cron using a cron table called crontab to
determine the schedule and commands.
Scheduling your tasks enables automation of routine tasks
or commands that you need to enter.
So far in this course we had to enter the command
suricata‑update every time we wanted to update a rule set.
Using cron,
we can schedule Suricata rule updates to occur at
regular intervals on our server.
This will help us ensure that we have the latest rules without
having to remember to manually update the server.
Let's take a quick look at an example cron table.
This slide is part of the text from the crontab file,
along with an example command to run suricata‑update.
As you can see,
the crontab includes helpful instructions for how to
structure the table and schedule tasks.
An important item to note.
By default, the output from a cron job is sent through email to the user.
We'll redirect the output to a log file to prevent this,
like the example command at the bottom.
This command will run at 12:28 pm on any day and output
to a file called suricata‑cron.log.
In the next demo,
we'll use the crontab on our server to schedule Suricata rules updates.
This will help us ensure that our rules are regularly updated
by scheduling suricata‑update commands to trigger the rule set
download and rule update process.
We'll also use the reload commands to minimize the
impact to Suricata's operation.