A Debian-first guide to identifying malicious scheduled tasks, reviewing recurring commands, and removing cron-based persistence safely.
Cron allows commands and scripts to run on a schedule. Attackers often abuse it for persistence, repeated downloads, outbound callbacks, log cleaning, or re-launching malicious processes after reboot.
A suspicious cron job may be obvious, or it may be buried in a user crontab, system cron directory, or hourly task.
/tmp, hidden directories, or odd home pathscrontab -l
sudo crontab -l
sudo find /etc/cron* -type f -maxdepth 2 -exec ls -lah {} \; -exec cat {} \;
sudo grep -R -Ei "curl|wget|bash|sh |python|perl|nc |ncat|socat|/tmp|/dev/shm" /etc/cron* /var/spool/cron 2>/dev/null
sudo journalctl --since "24 hours ago" | grep -i cron
sudo crontab -e
crontab -e
sudo ufw deny out to <IP_ADDRESS>
ps auxf
sudo kill -TERM <PID>
sudo ls -lah /path/to/script
sudo cat /path/to/script
file /path/to/script
sudo systemctl list-unit-files --type=service
sudo find /tmp /var/tmp /dev/shm -type f 2>/dev/null
cut -d: -f1 /etc/passwd
getent group sudo
Recovery means removing the scheduled task, understanding what it launched, and checking whether another persistence method exists.
crontab -l
sudo crontab -l
sudo find /etc/cron* -type f
sudo ls -lah /tmp
sudo ls -lah /dev/shm
sudo ls -lah /var/tmp
cut -d: -f1 /etc/passwd
sudo systemctl list-units --type=service --state=running
sudo ufw allow from <trusted_ip> to any port 22
sudo ufw deny 22
sudo apt update
sudo apt upgrade
Manual cron review should come first. Future recommendations may include options that improve service visibility or scheduled task monitoring, but the core workflow remains simple, transparent, and Debian-first.
All commands shown are based on Debian-based systems unless otherwise noted.