Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
FREEDOM251

Freedom251 › Blog › Automation

How to Schedule Bulk Screenshots of Indian Websites with Cron

By Freedom251 Team · · 7 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use cron to run a browser script on a schedule; use Playwright in that script to visit each authorized URL and save its screenshot. For dependable daily captures, set the host to the intended timezone, install the matching Playwright browser and system dependencies, use absolute paths, and run the command as the same account that owns the crontab.

Build a reliable scheduled capture

  1. Make a URL inventory. Store one authorized URL per line in a text file. Decide whether each image should show a fixed viewport or the entire scrollable page.
  2. Install Playwright and its browser. In the project directory, run npm init -y, then npm install playwright and npx playwright install --with-deps chromium on a supported Linux host. The browser binaries are tied to Playwright versions; repeat the browser installation workflow after upgrading. See the Playwright browser installation guide.
  3. Create the capture script. The example below reads a URL per line, captures pages sequentially, and records failures without silently treating them as successful images.
  4. Test as the cron owner. Run the command manually under the same account and with the same working directory, environment, and output permissions as the scheduled job.
  5. Add and verify the schedule. Use the intended host timezone, redirect logs to a writable absolute path, and check successive runs for exit status, expected image count, and content readiness.

Runnable Playwright script

Save this as capture.mjs in the project directory. Create urls.txt beside it, with one URL on each line. The script uses full-page capture; remove fullPage: true for fixed-viewport screenshots.

As an Amazon Associate I earn from qualifying purchases.

import { chromium } from 'playwright';
import { readFile, mkdir } from 'node:fs/promises';
import path from 'node:path';

const root = path.dirname(new URL(import.meta.url).pathname);
const urlsFile = path.join(root, 'urls.txt');
const outputDir = path.join(root, 'screenshots');
const urls = (await readFile(urlsFile, 'utf8'))
  .split(/r?n/)
  .map(line => line.trim())
  .filter(line => line && !line.startsWith('#'));

await mkdir(outputDir, { recursive: true });
const runId = new Date().toISOString().replaceAll(':', '-');
const browser = await chromium.launch({ headless: true });
let failures = 0;

try {
  for (const [index, url] of urls.entries()) {
    const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
    try {
      const response = await page.goto(url, {
        waitUntil: 'domcontentloaded',
        timeout: 60000
      });
      if (!response || !response.ok()) {
        throw new Error(`Navigation returned ${response?.status() ?? 'no response'}`);
      }
      // Replace or supplement this with a site-specific readiness condition.
      await page.screenshot({
        path: path.join(outputDir, `${runId}-${index + 1}.png`),
        fullPage: true
      });
      console.log(`OK ${url}`);
    } catch (error) {
      failures++;
      console.error(`FAIL ${url}: ${error.message}`);
    } finally {
      await page.close();
    }
  }
} finally {
  await browser.close();
}

if (failures) process.exitCode = 1;

domcontentloaded is a starting point, not proof that a site’s charts, images, or client-rendered data are ready. When a page has a stable landmark, wait for it before capturing—for example, add await page.locator('main').waitFor({ state: 'visible', timeout: 30000 }); after navigation, replacing main with a selector that genuinely indicates readiness on that site. For pages with no reliable landmark, choose and document an appropriate delay or other condition instead of assuming one wait strategy fits every URL. The Playwright Page API documents navigation and screenshot methods, and its screenshot guide covers viewport and full-page capture.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the screenshot shape and naming strategy

Viewport or full page

Choice Use it when Trade-off
Viewport You need a consistent visible frame for repeated comparison. Content below the viewport is not included; output is bounded by the chosen viewport.
Full page You need the complete scrollable document in one image. Long pages can produce very tall images and larger files.

Playwright rendering can vary with operating system, browser version, settings, hardware, power source, and headless mode. For visual comparisons, keep the capture environment and browser version consistent with the baseline; record those details with the output if others will compare images. See Playwright’s visual comparison guidance.

#1 Best Overall

The example names files with a run timestamp and sequence number. For larger inventories, a sanitized hostname can make files easier to identify, but include a collision-safe component: multiple URLs may share a host, and repeated runs should not overwrite prior evidence. Ensure the output directory is writable by the crontab owner.

Schedule the script with cron

For a daily run at 06:30 on a host whose cron daemon uses Indian Standard Time, an illustrative crontab entry is:

30 6 * * * cd /absolute/path/to/project && /usr/bin/node /absolute/path/to/project/capture.mjs >> /absolute/path/to/project/capture.log 2>&1

Edit the crontab for the account that should own the job with crontab -e. Cron runs commands as that crontab’s owner and uses the configured shell; setting the directory explicitly and using absolute paths avoids relying on an interactive shell’s working directory or PATH. Confirm the actual Node path with command -v node while logged in as the job owner.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Dell Latitude 5420 14" FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
  • 256 GB SSD of storage.
  • Multitasking is easy with 16GB of RAM
  • Equipped with a blazing fast Core i5 2.00 GHz processor.

A crontab uses five schedule fields—minute, hour, day of month, month, and day of week—before the command. In the Cronie manual, when both day-of-month and day-of-week are restricted, either matching field can trigger a run. Confirm the behavior of the cron implementation installed on your host. Cronie documents crontab -T as a syntax check where supported. The crontab(5) manual also documents CRON_TZ for Cronie, but that extension is not portable to every cron implementation. Check the daemon’s timezone and implementation rather than assuming a setting will be honored; job log timestamps in the cited manual use the daemon’s local timezone.

Run locally or on an always-on host

Environment Advantages Considerations
Existing Linux machine or server Uses infrastructure and access you already control. It must be on and reachable at the scheduled time, with browser dependencies installed and storage available.
Hosted Linux environment Can run independently of a personal computer’s availability. Requires hosting setup and may add service and maintenance costs; no provider or price is implied here.

For a large URL list, the script above intentionally captures sequentially. Parallel browser sessions can reduce elapsed time but increase CPU and memory use, affect stability, and create more load on destination sites. Start sequentially, observe run duration and host resources, then introduce limited concurrency only if the machine has capacity and the sites’ policies permit the request rate. Playwright’s CI guidance recommends one worker for stability and reproducibility in CI, while allowing parallel work on capable self-hosted systems; that advice is a useful starting point, not a universal limit for screenshot scripts.

Troubleshoot missed or misleading captures

  • The job works interactively but cron produces no files: run it as the crontab owner, set the project directory in the command, use absolute paths, and inspect the redirected log. Check write permissions for both the screenshots directory and log.
  • Chromium fails to launch: install the browser version matching the installed Playwright package and the required Linux system dependencies. After a Playwright upgrade, rerun the documented browser installation command; see the browser guide.
  • The screenshot is blank or incomplete: navigation completion may precede client-side rendering or image loading. Wait for a site-specific visible selector or another meaningful readiness condition, and log failures instead of saving a partial result as valid.
  • A URL times out: inspect the URL and the logged navigation failure, set a bounded timeout appropriate to the target set, and decide whether that URL should be retried on a later run. No single timeout or retry count suits every site.
  • Images differ between runs: control the operating system, Playwright/browser versions, viewport, and headless settings. Hardware and power conditions can also affect rendering, so keep the environment consistent when comparing images.
  • The run misses the intended local time: verify the daemon’s timezone and cron implementation. Do not rely on Cronie’s CRON_TZ extension unless the host supports it; validate the scheduled time with observed runs.
  • Only some URLs fail: preserve each URL’s status in the log and inspect failures individually. Capture only pages you are authorized to access, respect site terms and access controls, and do not attempt to evade technical restrictions.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo provides a screenshot API and MCP server. To request an image in a scheduled script, call its endpoint with your API key and target URL; consult the ScreenshotNeo documentation for request options and response handling.

Rank #3
15.6 Inch Win 11 Laptop Computer, N4020, 4GB DDR4 RAM, 128GB Storage | LPDDR4 RAM, 180° Lay-Flat, Dual-Band WiFi, Type-C PD Fast Charging, Thin & Lightweight for Students, Home & Office, Gray
  • WINDOWS 11 | STABLE PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 system, this laptop delivers stable performance for everyday computing tasks. It supports web browsing, online learning, document editing, email communication, and basic office work with optimized power efficiency, providing a practical and reliable experience for essential daily use for daily use.
  • 15.6” FHD IPS DISPLAY: Features a 15.6-inch Full HD IPS display with narrow bezels, offering wider viewing angles and clearer image details compared to standard panels. The improved screen-to-body ratio enhances visual experience for study, reading, document work, and video playback, making it suitable for both productivity and entertainment use.
  • 4GB DDR4 + 128GB eMMC STORAGE: Equipped with 4GB DDR4 memory and 128GB eMMC storage for everyday basics such as browsing, documents, email, and online learning platforms. The built-in TF card slot supports storage expansion up to 1TB, giving you more flexibility for files, photos, videos, and daily documents. TF card not included.
  • CONNECTIVITY & PORTS: Includes 1× TF card slot, 2× USB 3.2 Gen1 ports, and 2× full-featured Type-C ports (USB 3.2 Gen1). The Type-C ports support data transfer, charging, and video output, enabling flexible connection with external devices such as monitors, storage, and peripherals for daily work and study use.
  • LIGHTWEIGHT DESIGN | ONLINE COMMUNICATION: Designed with a slim, portable profile, this laptop is easy to carry for school, commuting, and travel. A built-in 1MP front camera supports online classes, video meetings, remote communication, and everyday conferencing. The 3300mAh battery works with the low-power system design to support practical daily use, while thermal optimization helps maintain quieter operation during extended tasks.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo removes cookie/consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, failed loads, timeouts, and cache hits are not billed. Its MCP server gives AI agents tools to take screenshots, get page information, and capture PDFs. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.

FAQ

Can one cron job capture a list of websites?

Yes. Have the scheduled command run one script that reads the URL inventory and processes each entry, as in the example. A single job makes it easier to manage one schedule and one log.

Will a full-page screenshot always include lazy-loaded images?

Not necessarily. Full-page capture includes the scrollable document, but pages may load images or other content only after scrolling or waiting. Add site-appropriate scrolling or readiness logic when the page requires it.

How can I check whether cron ran?

Inspect the log file configured by the crontab entry, then check the output directory for the expected run’s files. A nonzero script exit status also signals that at least one URL failed in the sample script.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

AutomationCronLinuxPlaywrightwebsite screenshots

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.