Run a headless Playwright script on a fixed schedule via cron or a systemd timer

domain: playwright.dev · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Install Playwright and its browsers with npx playwright install (add --with-deps on minimal Linux CI images to also install OS-level dependencies)
  2. Keep the script headless (Playwright's default) — no DISPLAY/Xvfb is required for headless Chromium/Firefox/WebKit
  3. Note where browser binaries are cached so cron's minimal environment can find them (default is a per-user cache directory), or override the location via the PLAYWRIGHT_BROWSERS_PATH environment variable
  4. In the crontab or systemd timer/service unit, use absolute paths for the node binary, script, and working directory, since cron/systemd run with a minimal, non-login environment that does not source shell rc files
  5. Redirect stdout/stderr to a log file, or rely on systemd's journal when using a timer+service unit, so failures are diagnosable after unattended runs
  6. Re-run npx playwright install after upgrading the Playwright package, since browser binary versions are pinned per release

Known gotchas

Related routes

Run headless browser tests reliably in CI containers, handling display server, font, and codec requirements
playwright.dev · 5 steps · unrated
Control timers and fake the system clock in Playwright tests using page.clock
playwright.dev · 5 steps · unrated
Make headless-browser file downloads deterministic by awaiting the download event/promise instead of polling the filesystem
playwright.dev · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans