Configure system-wide recurring tasks using the correct cron interval directories and enforce executable permissions. Validate placement by enumerating the cron directories and confirming each script’s purpose and run frequency.
Your team needs you to configure system-wide recurring tasks that run at predictable intervals. You must place scripts in the correct cron interval directories so the system scheduler runs them automatically, and you must ensure scripts are executable so they actually fire.
This is the kind of baseline automation that prevents log sprawl, keeps backups consistent, and makes routine maintenance repeatable without someone manually running commands.
/etc/cron.hourly
.
/etc/cron.daily
.
/etc/cron.monthly
.
/etc/cron.*
and confirming scripts exist and are executable.
/etc/cron.hourly
,
/etc/cron.daily
,
/etc/cron.weekly
, and
/etc/cron.monthly
.
vim
.
chmod +x
so cron can run your scripts.
find
,
tar
, and
rsync
in scripts.
ls
to confirm interval directories and scripts.
cd /etc/cron.*
The interval directories under
/etc
are the system-wide drop-in locations for recurring tasks.
On many systems, scripts placed here are executed by the
system cron framework at the matching frequency.
# Common directories:
# /etc/cron.hourly
# /etc/cron.daily
# /etc/cron.weekly
# /etc/cron.monthly
sudo vim /etc/cron.hourly/cleanup_logs
Hourly tasks are for small, frequent maintenance operations. This example removes older log files to reduce disk growth. Keep these scripts fast and predictable.
#!/bin/bash
find /var/log -type f -name '*.log' -mtime +3 -delete
sudo chmod +x /etc/cron.hourly/cleanup_logs
Cron interval directories generally require executable scripts. If the file is not executable, it may be skipped even if it exists in the correct location.
# Confirm executable bit:
# -rwxr-xr-x ... /etc/cron.hourly/cleanup_logs
sudo vim /etc/cron.daily/backup_home
Daily tasks are a good fit for backups and reports. This
script generates a dated archive of
/home
to a backup location.
#!/bin/bash
tar -czf /backup/home_$(date +%F).tar.gz /home
sudo chmod +x /etc/cron.daily/backup_home
If you ever wonder why a cron directory script is not running, executable permissions are one of the first things to check.
# Confirm executable bit:
# -rwxr-xr-x ... /etc/cron.daily/backup_home
ls /etc/cron.*
This is your fast placement check. Confirm scripts exist in
the intended directories and remember that
/etc/cron.weekly
and
/etc/cron.monthly
are also valid drop-in targets for longer cadence tasks.
/etc/cron.daily/backup_home
/etc/cron.hourly/cleanup_logs
/etc/cron.weekly/
/etc/cron.monthly/
sudo vim /etc/cron.monthly/monthly_sync
Monthly tasks are useful for archive rollups and long-term retention workflows. This example syncs backups to a NAS location.
#!/bin/bash
rsync -av /backup/ /mnt/nas/monthly_archive
sudo chmod +x /etc/cron.monthly/monthly_sync
The executable bit is required here as well. Once set, this script is eligible to run on the monthly schedule provided by your system cron configuration.
# Confirm executable bit:
# -rwxr-xr-x ... /etc/cron.monthly/monthly_sync
/etc/cron.hourly
: Drop-in directory for scripts executed on an hourly basis.
/etc/cron.daily
: Drop-in directory for scripts executed daily.
/etc/cron.weekly
: Drop-in directory for scripts executed weekly.
/etc/cron.monthly
: Drop-in directory for scripts executed monthly.
vim
: Create or edit maintenance scripts.
chmod +x <file>
: Marks a script as executable so it can be run by the cron framework.
ls /etc/cron.*
: Verifies directory presence and confirms script placement.
find
: Used for log cleanup operations (filter files and delete old logs).
tar
: Creates compressed archives for backups.
rsync
: Synchronizes files and directories for archive replication.