A ledger of AI tools and building sites for overseas traffic.

Home / Workflows & MCP / Four ways to schedule tasks: what's beyond cron

Four ways to schedule tasks: what's beyond cron

cron is simple but hard to monitor. systemd timers, container schedulers and in-app scheduling each trade off differently.

Oct 26, 2026 3 min read naket.top Updated 2026-11-01
Four ways to schedule tasks: what's beyond cron

"Run a script at a certain time every day" is something cron can handle, but it has three weak spots: logs are hard to find, failures go unnoticed, and the timezone depends on the host.

Comparing the four options

cronsystemd timerContainer schedulingIn-app
Getting startedSimplestMediumMediumDepends on framework
LogsYou redirect them yourselfCollected automatically by journaldBuilt into the platformApplication logs
Retry on failureNoneLimitedYesCustomizable
Dependency managementNoneYes (unit dependencies)YesYes
Best forSimple scriptsSystem-level tasksMulti-machine deploymentsTasks inside a business app

Using cron correctly

# Run backup daily at 03:10, write logs to disk by date
10 3 * * * /usr/local/bin/backup.sh >> /var/log/backup/$(date +\%F).log 2>&1

Two details: % must be escaped inside crontab; the environment is minimal, so use absolute paths in the script.

When to switch to a systemd timer

If you need a missed run to be caught up (Persistent=true), need the job tied to a service's startup, or need logs in one place — any one of these means switch to systemd.

[Timer]
OnCalendar=*-*-* 03:10:00
Persistent=true

Persistent=true is something cron can't give you: if the machine was off and the run was missed, it runs once after boot.

Where in-app scheduling fits

Business tasks (say, "clean up expired drafts every day") are better off inside the application, because they need access to the app's data layer and config. Putting them in cron tears the business logic in two.

Monitoring is the shared problem

Whichever you use, you have to be able to answer two questions: Did the last run succeed? How long did it take?

The cheapest approach is to write one line of status to a fixed file when the job finishes, and have a health check read it. Without this step, every option is "it ran and then who knows".

Trade-offs for the five options

  • cron: only good for fire-and-forget scripts. If you want logs and retries, you write them yourself.
  • systemd timer: the first choice for system-level tasks; Persistent=true catches up missed runs.
  • Container scheduling (K8s CronJob, docker timers): for multi-machine setups that need unified observability.
  • In-app scheduling (Laravel Schedule, Spring Task): the first choice for business tasks; it can use the app's config and data layer directly.
  • External hosting (cloud function scheduled triggers): for cases where "the machine might be off".

One rule of thumb

If a task depends on local state (reads local files, connects to a local database), keep it on the machine; if it just calls an API, external hosting is less hassle.

How to write the monitoring

# Write a status line at the end of the task
echo "$(date -Is) ok $SECONDS" >> /var/log/jobs/backup.status

The health check reads the last line: if it hasn't been updated in over 26 hours, alert. That one line is cheaper than any monitoring system.

Also, keeping the job in the codebase instead of in crontab means it's version-tracked, moving to another machine only requires reinstalling dependencies, and you never hit "this machine's crontab doesn't match the docs".

cronsystemdscheduling

Further reading

systemd.timer manual ↗ crontab manual ↗