Persistence by scheduled task: tasks, cron jobs, and launch agents
Scheduled tasks and cron jobs let code run again after reboot. Which events record their creation on Windows, Linux, and macOS, what a suspicious task looks like, and how to review them with built-in commands.
Diagram
A task that does not belong
Step 1 of 4
Created
Windows logs the new task.
Security 4698: A scheduled task was created Task Name: \Microsoft\Windows\UpdateCheck Author: FIN-LT-044\ana
The example on the open step is one illustration, or the fix you can paste into an application you own.
What this page is made of
3 pieces. Each one says what fails, who is affected, what you would notice, and what you change.
Names that blend in
- What fails
- Tasks are named to look like vendor maintenance.
- Who is affected
- The host.
- What you would notice
- Tasks under Microsoft paths authored by a normal user.
- What you change
- Check author and action, not just name.
User-writable paths
- What fails
- Tasks running scripts from Public, Temp, or AppData.
- Who is affected
- The host and its user.
- What you would notice
- Actions pointing into user-writable folders.
- What you change
- Alert on tasks whose action path is writable by users.
Linux timers and cron
- What fails
- Cron and systemd timers do the same on Linux.
- Who is affected
- Servers.
- What you would notice
- New files in /etc/cron.d or new timer units.
- What you change
- Monitor those paths with auditd or file integrity monitoring.
Collecting at scale
Autoruns from Sysinternals lists every persistence location on a Windows host. Across a fleet, osquery’s scheduled_tasks and crontab tables or Velociraptor artifacts collect the same data so you can find rare entries; the osquery and Velociraptor lessons in the tool library show those queries.
osquery> SELECT name, action, path, last_run_time FROM scheduled_tasks WHERE action LIKE '%Users\Public%';
Check yourself
Recognition and the fix. Nothing here is a procedure.
Which Windows event ID records a new scheduled task?
Sibling techniques
Pages at the same depth, plus a lab and a glossary card for this one.
This page stands on its own. The lab and the glossary card are the next reading.