clamAV-Utils
Python 3
Bash
ClamAV
multiprocessing
tqdm
Security
Ventana de terminal Ventana de terminal Ventana de terminal
Ventana de terminal
GitHub: stevenvo780/clamAV-Utils
What it is
Sección titulada «What it is»clamAV-Utils provides a parallel, scriptable wrapper around ClamAV (clamdscan / clamscan) that makes large filesystem scans practical: it batches files, distributes batches across CPU cores, shows a live progress bar, quarantines infected files, and writes structured logs — all from a single CLI command.
The repo contains two implementations:
| File | Approach |
|---|---|
antivirus.py | Python 3 — multiprocessing.Pool, tqdm, argparse, full quarantine support |
cleanVirus.sh | Bash — GNU parallel + pv, auto-installs deps via apt, simpler but less configurable |
antivirus.py is the primary tool. cleanVirus.sh is an older approach kept for reference.
How it works
Sección titulada «How it works»antivirus.py scans one or more directories in parallel:
- Walk: recursively lists all files under the target directories; skips unreadable files with a warning.
- Exclude system dirs:
/proc,/sys,/dev,/run,/tmp,/var/lib,/var/runare excluded by default to avoid spurious errors and infinite loops. - Batch: divides the file list into batches (default 500 files per batch).
- Parallel scan: submits batches to a
multiprocessing.Pool; each worker callsclamdscan(preferred) orclamscanas a subprocess. - Quarantine: if
--quarantine-diris specified, infected files are moved there viaclamdscan --move=<dir>. - Progress:
tqdmshows a live progress bar with batch count and ETA. - Logging: every scan event (clean, infected, error, permission denied) is appended to the log file.
Installation
Sección titulada «Installation»git clone https://github.com/stevenvo780/clamAV-Utils.gitcd clamAV-Utils
# Install ClamAV (Debian/Ubuntu)sudo apt install clamav clamav-daemon
# Install Python dependencypip install tqdm
# Update virus definitionssudo freshclamsudo pacman -S clamavpip install tqdm
# Enable and start the ClamAV daemonsudo systemctl enable --now clamav-daemonsudo freshclam# cleanVirus.sh auto-installs its own deps via apt:# clamav, parallel, pv# Just run it directly:bash cleanVirus.sh /home /var/www# Basic scan of home directorypython3 antivirus.py /home
# Scan multiple directories with 8 parallel workerspython3 antivirus.py /home /var/www -j 8
# Quarantine infected filespython3 antivirus.py /home --quarantine-dir /var/quarantine
# Update virus definitions first, then scanpython3 antivirus.py /home --update-db
# Custom batch size and log filepython3 antivirus.py /home --batch-size 200 --log-file /var/log/myscan.log
# Exclude additional directoriespython3 antivirus.py /home --exclude-dirs /home/user/.cache /home/user/.local/share/Steam
# Use all cores except 2 (leave headroom for other processes)python3 antivirus.py /home --nucleos-libres 2CLI reference
Sección titulada «CLI reference»| Argument | Default | Description |
|---|---|---|
directories | (required) | One or more paths to scan |
-j, --jobs | CPU count | Number of parallel worker processes |
--nucleos-libres | 0 | Reserve N cores — effective jobs = CPUs − N |
--exclude-dirs | system dirs | Additional directories to skip |
--quarantine-dir | (none) | Move infected files here instead of leaving them in place |
--log-file | clamav_scan.log | Path to the output log file |
--batch-size | 500 | Files per batch sent to each worker |
--update-db | off | Run freshclam before scanning |
| Layer | Technology |
|---|---|
| Scanner | ClamAV (clamdscan / clamscan) |
| Parallelism | Python multiprocessing.Pool |
| Progress bar | tqdm |
| CLI | argparse |
| Quarantine | clamdscan --move + shutil |
| Logging | Python logging (file + stderr) |
| Bash variant | GNU parallel + pv |