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.

Lesson 12 of 16 · 10 min read · practice only with authorization

Diagram

A task that does not belong

Follow the path. One example at a time.

Step 1 of 4

Created

Windows logs the new task.

Illustration: Created
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.

  1. 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.
  2. 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.
  3. 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.

1 / 3

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.

Practice

  1. LabTerminal mission: A telemetry task that is not from OfficeTrace a VBScript from a zipped invoice through Sysmon process events to the scheduled task it created. Name the task, its interval, and the script it keeps re-running.

Glossary

  1. CardPersistence by scheduled taskA task or a service starts a program at boot so access survives a reboot.