
crontab
crond is the background service responsible for managing scheduled tasks on Linux systems, including RHEL. It runs in the background and executes commands or scripts at specified times using cron jobs.
​
Key Features:
-
Allows users to automate repetitive tasks like backups, log rotation, and scripts
-
Uses the crontab (cron table) to define jobs with scheduling syntax (* * * * *).
-
Supports system-wide and user-specific job scheduling.
-
Logs executions in /var/log/cron for troubleshooting.
RHEL & Crontab
Schedule with crond
# -- Open Crontab in Nano --#
export VISUAL=nano
crontab -e
​
# -- Add Daily Schedule --#
#-- https://crontab.guru/ --#
0 2 * * * /usr/bin/python3 /opt/scripts/system_report.py
​
# -- Verify Job Exists --#
crontab -l
Logic:
I wanted a simple but useful task to add to my Splunk logging. I have the firewalld settings logging to my Spunk server. I then have a daily snapshot of what services and port I had open each day. I could if needed then go back and see what ports may have been added and when.
Requirements
-
python3 package installed
-
cron service running
-
logger command
​
Optonal :
-
Rsyslog forwarder to Splunk
Firewalld Service Info Script
Create directory and file called system_report.py and make it executable.
​​​
#Create DIR
sudo mkdir /opt/scripts
​
# Set User and Group Ownership on DIR
sudo cd /opt
sudo chown shead:mynfs scripts
​
# Create FIle
cd /opt/scripts
touch system_report.py
​​
​​
# Set Execute Permissions
chmod u+x /opt/scripts/system_report.py​​​

Result | Splunk Query
index="linux_logging" host=rhel9200 firewalld
| fields host, _time, _raw
| table host, _time, _raw
