Use Playwright to capture the page in Node.js, then use cron to start the script at the times you choose. The Node process can exit after each capture; cron handles the schedule. The essential pieces are a browser runtime available to the scheduled process, a script that closes its browser even when capture fails, and absolute paths and logs in the cron entry.
What the setup does
Playwright opens a browser, navigates to a URL, and saves a screenshot. Cron is the operating-system scheduler: it launches the Node.js script on a recurring schedule. This is different from a Node.js timer, which only runs while its process remains alive.
The example below uses the Playwright Node.js API documented at Playwright: Screenshots. It illustrates the documented API flow; it is not a claim that this exact script has been tested.
Install Playwright and create the capture script
Install the project dependency and browser
From the project directory, install Playwright and its Chromium browser. The scheduled account must be able to access this project and the browser runtime.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
npm init -y
npm install playwright
npx playwright install chromium
Save the screenshot script
Create capture.js in the project directory. This version captures the full scrollable page, writes a PNG, and closes Chromium whether navigation or capture succeeds or fails.
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
try {
const page = await browser.newPage();
await page.goto('https://example.com', { waitUntil: 'load' });
await page.screenshot({ path: 'screenshot.png', fullPage: true });
} finally {
await browser.close();
}
})().catch((error) => {
console.error(error);
process.exitCode = 1;
});
Replace the example URL with the page you need. The relative output path is resolved from the process working directory, so the cron job below sets that directory explicitly. This basic script overwrites screenshot.png on each run; use a timestamped or otherwise unique filename if you need to retain a history of captures.
Choose the capture shape and file format
Viewport or full page
With fullPage: true, Playwright captures the full scrollable document. Omit that option for a screenshot of the current viewport. Use a viewport capture when the artifact should represent a particular screen, and full-page capture when you need the whole document.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Scale, format, and output size
Playwright supports screenshot output paths, image formats, quality, clipping, full-page capture, and scale choices. PNG is a straightforward lossless choice for archiving or visual comparison. Other supported formats can reduce file size; select the format and quality for how the result will be used. CSS-pixel scale can keep high-density captures smaller, while device-pixel scale follows device pixel density and can produce larger images. See the screenshot options documentation for the available API settings.
Recommended Free Tools
Schedule it with cron
Use absolute paths and an explicit working directory
First find the absolute paths to the Node executable and project directory in the same environment that will run the job. Cron often runs with a more limited environment than an interactive shell; do not assume your usual PATH or current directory. The following example runs every day at 09:00 according to the host’s cron and timezone configuration. Replace both paths with the real values for your machine.
0 9 * * * cd /absolute/path/to/project && /absolute/path/to/node capture.js >> /absolute/path/to/project/capture.log 2>&1
Edit the crontab for the account that should own the job:
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
crontab -e
Add the schedule line, save, and confirm the host’s timezone and cron implementation. The example’s time is not a promise of the same local run time on every host. Cron’s role as a time-based job scheduler is described in the crontab manual.
Check the result and logs
Run the script manually from the project directory once before relying on its schedule. Check that the screenshot appears where expected, then inspect the configured log after a scheduled run. Standard output and errors are appended to capture.log by the example, which helps diagnose failures without keeping a Node.js process running between captures.
Make scheduled captures useful for monitoring
Keep the environment stable for visual comparisons
A scheduled screenshot is not guaranteed to be pixel-identical from run to run. Playwright notes that rendering can vary with the host operating system, browser version, hardware, power source, and headless mode. For meaningful visual baselines, create and check screenshots in the same environment; control dynamic page content where appropriate, and review diffs rather than treating every changed pixel as a defect. See Playwright’s visual comparison guidance.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Record time and failures
A successful schedule does not guarantee that the site is available or that its content is in the same state each time. Keep timestamps with retained screenshots and log navigation or capture failures. Decide how long to retain files and where to store them based on your monitoring needs; the capture API does not set a retention policy for you.
Use repeat captures when checking visual baselines
Playwright Test’s screenshot assertion can capture repeatedly until two consecutive screenshots match, then compare the last capture with its expectation. That can help with visual checks where rendering is still settling. It is separate from the basic one-shot script above; see the screenshot assertion documentation.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Choose cron or a hosted scheduled workflow
Cron is suitable when you control a host with Node.js, project dependencies, and the browser runtime installed. A hosted workflow may suit you if you do not want to operate a persistent host, but check that platform’s schedule semantics, availability, and limits before deployment. GitHub documents workflow syntax at GitHub Actions workflow syntax; the documentation should be consulted for the configuration and guarantees applicable to your workflow.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesBest Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Compare the options by who maintains the browser runtime, where screenshots are stored and retained, what timezone and schedule controls are available, whether the job can access authenticated or private sites, and whether you can keep the browser and operating-system environment stable for comparisons.
Troubleshoot common failures
- The job works in a terminal but not from cron: cron may not inherit your interactive PATH or working directory. Use absolute paths for Node and the project, and include
cdbefore running the script. - No screenshot appears: check the log for navigation or file-write errors, confirm the output directory is writable by the cron account, and verify that the script’s relative output path resolves from the working directory in the cron line.
- The browser does not launch: verify that Chromium was installed for the project and is available to the scheduled environment. Install dependencies and the browser in the same environment that runs the script.
- The page appears incomplete or changes between captures: page availability and dynamic content can affect what is captured. Keep the browser and host consistent for comparisons and review the log and screenshot timestamp alongside the page state.
- The file is overwritten each run: the example deliberately writes to the same filename. Change the output path to a unique name per run if you need historical captures.
Or skip the browser setup
If you do not want to install and maintain Playwright and a browser runtime, ScreenshotNeo offers a website screenshot API and MCP server. One GET request can return an image or PDF. Here is the cURL form, using the documented API endpoint and parameters; see the ScreenshotNeo API documentation for configuration details.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
ScreenshotNeo accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response indicates the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Every feature is on every plan.
Sign up for ScreenshotNeo’s free plan.
Frequently Asked Questions
Can I use a Node.js timer instead of cron?
Yes, but the Node process must stay running for its timer callbacks to fire. Cron can start a short-lived capture process on schedule and let it exit.
Can scheduled captures be pixel-identical every time?
Not necessarily. Browser and rendering output can vary with the operating system, browser version, hardware, power source, and headless mode.
Quick Recap
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.




