October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk6 min

How to Schedule Selenium Website Screenshots with Cron

A practical guide to capturing website screenshots with Selenium and scheduling the script with cron, including headless Chrome, cron setup, and troubleshooting.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Selenium to open the page and save its screenshot; use cron to run that script on a schedule. You need a working browser and WebDriver setup, a script that waits for the page content you want, and a cron entry that uses the correct paths and environment for the account running it.

What you need before scheduling a screenshot

Cron does not install or manage Selenium, the browser, or its driver. Set up those components for the host and language binding you plan to use. Selenium’s Getting Started documentation describes the setup components, and Selenium Manager can help manage browser drivers. Check the instructions for your chosen browser and its version.

As an Amazon Associate I earn from qualifying purchases.

  • A Selenium language binding; the example below uses Python.
  • A browser such as Chrome and a compatible driver setup.
  • A directory writable by the account that will run the scheduled job.
  • Cron installed and configured on the host. Cron behavior and logging vary by implementation.

Write a Selenium script that captures the page

Save this as /home/alex/bin/site_screenshot.py, replacing the URL and output location. It waits for the document to finish loading, saves a PNG to an absolute path, and quits the browser even if an error occurs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
from pathlib import Path
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

url = "https://example.com/"
output = Path("/home/alex/screenshots/example.png")
output.parent.mkdir(parents=True, exist_ok=True)

options = Options()
options.add_argument("--headless=new")

# Selenium Manager can assist with driver management when supported by
# your Selenium and browser setup.
driver = webdriver.Chrome(options=options)
try:
    driver.get(url)
    driver.save_screenshot(str(output))
finally:
    driver.quit()

Selenium’s Python example uses driver.save_screenshot('./image.png'); its API documents saving the current window to PNG and recommends a full path. See the Python WebDriver API. The example above waits for navigation, but a page that renders important content later may need an explicit wait for that content before the screenshot.

#1 Best Overall

Wait for the content you actually need

For a page that populates an element after navigation, wait for that element rather than relying on a fixed sleep. For example, add these imports and replace the immediate screenshot call with the wait shown here, changing the selector to one present on the target page:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

# After driver.get(url):
WebDriverWait(driver, 20).until(
    EC.visibility_of_element_located((By.CSS_SELECTOR, "main"))
)
driver.save_screenshot(str(output))

The timeout is a maximum wait for this example, not a guarantee that every page will be ready within that time. Choose a selector that indicates the content of interest is visible, and handle a timeout as a failed capture rather than silently saving an incomplete image.

Use headless mode when no desktop is available

A server without a graphical desktop generally needs Chrome configured for headless execution. Selenium’s Chrome guide lists --headless=new among commonly used arguments. Browser options can change, so confirm the appropriate option for your installed browser version in the Selenium Chrome documentation.

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

Test the script as the cron user

Before scheduling it, run the script from a shell as the same operating-system account whose crontab will own the job. For example:

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.
/usr/bin/python3 /home/alex/bin/site_screenshot.py

Use the interpreter path that exists on your host. Confirm that the screenshot is created at the expected location and that the job account can write to its parent directory. The Debian systemd-cron manual specifies that jobs run as the owner of the user’s crontab; other implementations should be checked against their own documentation.

Add a cron entry for the capture schedule

A per-user crontab schedule has five fields—minute, hour, day of month, month, and day of week—followed by the command. For instance, this runs every day at 06:30 according to the host’s cron scheduling and timezone:

30 6 * * * /usr/bin/python3 /home/alex/bin/site_screenshot.py >> /home/alex/screenshots/cron.log 2>&1

Install it in the intended user’s crontab with crontab -e. The Debian systemd-cron crontab manual documents the five time fields. Check your host’s cron implementation and timezone if the job runs at an unexpected time.

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

Do not mix per-user and system-wide crontab formats

In the cited Debian systemd-cron implementation, entries in /etc/crontab and /etc/cron.d include a username between the schedule and command. A per-user line cannot be copied into those files unchanged. Consult the local manual for the format your host actually uses.

Rank #3
15.6 Inch Laptop Computer, N4020, 4GB DDR4 RAM, 128GB eMMC,with Windows 11
  • EFFORTLESS EVERYDAY PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 Home system, delivering reliable, low-power efficiency for daily tasks like document editing, email, online classes, and web browsing
  • 15.6-INCH FULL HD DISPLAY: Enjoy immersive visuals on the 15.6" FHD (1920x1080) anti-glare screen with micro-edge bezels. Delivers clear details and comfortable viewing for long study sessions, working on spreadsheets, and video playback
  • RESPONSIVE MULTITASKING & STORAGE: Built with 4GB LPDDR4 RAM and 128GB eMMC storage for smooth daily essential use. Expand your storage by up to 1TB via the integrated TF card slot to easily store movies, photos, and working files
  • ADVANCED CONNECTIVITY: Outfitted with 2x Full-Featured Type-C ports for data transfer, fast charging, and dual-monitor output, alongside 2x USB 3.2 Gen1 ports and a 3.5mm audio jack for complete peripheral compatibility
  • LIGHTWEIGHT & SILENT OPERATION: Slim and portable for effortless travel or commuting. Features a 1MP HD webcam for remote meetings, 38Wh battery with 45W Type-C fast charging, and a fanless silent design for peaceful work environments.

Make the cron environment explicit

A cron job may not receive the same environment as an interactive login shell. The cited systemd-cron manual documents SHELL and PATH settings and says settings affect subsequent commands in the file. Prefer absolute paths for the interpreter, script, and output; define any required environment values deliberately instead of assuming shell startup files are loaded.

Keep and inspect job output

The example redirects both standard output and errors to a log file, which can help diagnose the first scheduled run. Ensure the directory for that log exists and is writable. Cron implementations and host configuration differ: job output may be handled through mail, a journal, or another logging route. The systemd-cron manual documents its job-output behavior, but the exact place to inspect output depends on your system.

Troubleshoot a job that fails under cron

If the script works when run interactively but not on schedule, check these in order:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Crontab and owner: confirm the entry is installed for the intended account and that this account can access the script and browser.
  2. Schedule and timezone: verify the five fields and the host’s timezone against when you expect the capture.
  3. Paths: use existing absolute paths for the Python interpreter, script, browser-related executables if needed, screenshot, and log.
  4. Environment: supply required PATH or other environment values explicitly; do not rely on an interactive shell profile.
  5. Browser and driver: run the script as the job user and resolve browser or driver setup errors before investigating cron itself. Selenium’s setup guide and browser-specific documentation cover these components.
  6. Headless configuration: on a host without a desktop, check that the browser is configured for headless execution and that the option matches its version.
  7. Output permissions: verify that the job user can create or overwrite the screenshot and log files.
  8. Captured errors: inspect the redirected output and the host’s cron logs or mail route, as applicable.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When one machine is no longer enough

A local WebDriver script is a straightforward fit for a modest recurring workload on one host. Selenium Grid is an option when browser execution needs to be distributed across machines or run in multiple browser environments. Selenium states, “The Selenium Server is needed in order to run Remote Selenium WebDriver (Grid).” See the Selenium Downloads page and its Grid documentation. Grid adds setup and operational complexity; the available sources do not establish comparative performance or cost figures.

Rank #4
15.6 Inch Win 11 Laptop Computer, N4020, 4GB DDR4 RAM, 128GB Storage
  • 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.

Or skip the browser setup

For a scheduled screenshot without managing a browser and driver on your own host, ScreenshotNeo offers a website screenshot API and MCP server. Its one-call API can return a screenshot; the documentation covers request options.

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 or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; these steps can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, with response headers indicating the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for AI agents using Claude, Cursor, or another MCP client. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.

Sign up for ScreenshotNeo’s free plan to try it with 1,000 screenshots a month and no card.

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

Frequently Asked Questions

Does cron take the screenshot itself?

No. Selenium performs the browser navigation and screenshot capture; cron starts the script at the scheduled time.

Can I use a Selenium language other than Python?

Yes. The example is Python, but Selenium provides multiple language bindings. Adapt the script and interpreter path to the binding you install.

Quick Recap

Bestseller No. 1
HP 14' HD Laptop, Windows 11, Intel Celeron Dual-Core Processor Up to 2.60GHz, 4GB RAM, 64GB SSD, Webcam, Dale Pink (Renewed)
HP 14" HD Laptop, Windows 11, Intel Celeron Dual-Core Processor Up to 2.60GHz, 4GB RAM, 64GB SSD, Webcam, Dale Pink (Renewed)
14" diagonal, 1366x768 resolution, HD BrightView LED, Glossy NON-TOUCH Display
$245.99
Bestseller No. 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)
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.
$285.00

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.

Leave a Reply

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

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.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

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.