To schedule recurring website screenshots with PhantomJS, write a JavaScript capture script, confirm it runs manually, then schedule the PhantomJS command with cron on Linux or Task Scheduler on Windows. Keep in mind that PhantomJS is legacy software: its project says development is suspended, and its upstream repository is archived and read-only. Check that it works with your host and target pages before relying on it.
Separate the capture from the schedule
PhantomJS is a headless, JavaScript-scriptable browser. Your script opens a page and renders it; the operating system’s scheduler launches that script at the times you choose. This division makes the job easier to test: first make a manual capture work, then schedule the same command.
As an Amazon Associate I earn from qualifying purchases.
The PhantomJS project states, “Important: PhantomJS development is suspended until further notice.” Its upstream GitHub repository is archived and read-only. The project’s published command-line material identifies 2.1.1 as its latest release. Do not assume its rendering, security, or web-platform behavior matches a current browser; validate it against the actual websites and machine you intend to use. This is best treated as a way to maintain an existing setup, not as a newly maintained browser automation stack.
Recommended Free Tools
Create and run a capture script
Save this as capture.js, changing the URL and output path. It follows the PhantomJS quick-start pattern: create a webpage, open the URL, render only after a successful load, then exit the process. PhantomJS quick start
#1 Best Overall
var page = require('webpage').create();
page.open('https://example.com/', function (status) {
if (status === 'success') {
page.render('/opt/capture/example.png');
} else {
console.log('Page failed to load: ' + status);
}
phantom.exit();
});
Use a full, absolute output path. A scheduled process may start in a different working directory from your interactive shell. This example uses one fixed filename, so each successful run overwrites the prior image. For a history of captures, change the script to create a unique filename for each run, for example by including a timestamp; ensure the destination directory exists and is writable by the account running the task.
- Find the PhantomJS executable path on the host where the schedule will run.
- Run it manually as the same operating-system account that will own the scheduled job:
/usr/local/bin/phantomjs /opt/capture/capture.js. Adjust both paths to your installation. - Check the exit behavior, log output, saved file, file permissions, and network access. If the target requires authentication or relies on modern browser features, test those conditions explicitly; this minimal example does not configure credentials or guarantee compatibility.
The PhantomJS command-line form is phantomjs [options] somescript.js [args...]. Command-line documentation
Choose capture dimensions and output
The capture guide documents PNG, JPEG, GIF, and PDF output, as well as viewport and clip-rectangle controls. Set the viewport dimensions in the page script when the browser window size matters. Set page.clipRect when you need a particular rectangle. A viewport-sized capture should not be assumed to include the full height of a long page. PhantomJS screen capture guide
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsRank #2
- Intuitive interface of a conventional FTP client
- Easy and Reliable FTP Site Maintenance.
- FTP Automation and Synchronization
Choose dimensions based on the screenshot’s purpose: a fixed viewport for consistent visual checks, or a clip rectangle for a known region. Test the resulting file on your target pages, particularly when content loads asynchronously. The capture example renders after the page-open callback succeeds; that alone does not establish that every delayed image, font, or client-rendered element has finished appearing.
Schedule the command on Linux with cron
For a daily run at 06:30 in the machine’s local timezone, add a crontab entry like this, replacing paths with the actual executable, script, and log locations:
30 6 * * * /usr/local/bin/phantomjs /opt/capture/capture.js >> /opt/capture/capture.log 2>&1
- Open the crontab for the account that should run the job with
crontab -e. - Add the entry, using absolute paths and the intended local schedule time.
- Save it, then check the crontab and log after the next due run. Confirm the output file changed or a new archive file appeared.
Cron reads crontab instructions to run commands at scheduled times; exact behavior and configuration can vary by system. Check that host’s crontab(1) and crontab(5) documentation. Linux crontab manual The machine must be running and able to reach the target when the job is due.
Rank #3
Schedule the command on Windows with Task Scheduler
In Task Scheduler, create a task with a recurring trigger and an action that starts the PhantomJS executable with the script path as its argument. Set the working directory and run account in the task’s properties where needed, and quote paths containing spaces.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →- Create a task and choose the trigger frequency, such as daily, weekly, or monthly.
- Set the action’s program to the full path of
phantomjs.exe; pass the full script path as an argument. - Set the appropriate account and working directory, then run the task manually from Task Scheduler and inspect its history and output location.
Microsoft’s schtasks command also supports recurring daily, weekly, and monthly schedule types. Requirements for creating or managing tasks can depend on the account and permissions; Microsoft documents administrator requirements for scheduling and managing all local tasks. Microsoft schtasks reference
Check time, account, and file behavior
- Timezone: Set the schedule for the host’s intended timezone, not an assumed timezone from another machine.
- Availability: The computer or server needs to be powered on and hosted when a run is due.
- Permissions: The scheduled account needs permission to execute PhantomJS, access the network, read the script, and write to the output directory.
- Output policy: Decide whether each run overwrites the prior screenshot or creates an archive, and check available disk space if retaining files.
- Diagnostics: Redirect cron output to a log or use Task Scheduler history so missed or failed runs are easier to investigate.
If a machine must remain available specifically for this job, hosting is one possible solution; verify that the chosen environment can run the legacy PhantomJS executable before depending on it.
Rank #4
Troubleshoot common failures
| Symptom | Likely cause | What to check |
|---|---|---|
| No screenshot appears | The job used a different working directory, the destination directory is missing, or the scheduled account cannot write there. | Use an absolute output path, create the directory, and check permissions as the scheduled account. |
| The task works manually but not on schedule | The scheduler uses a different account, environment, executable path, working directory, or timezone. | Run the exact command as the task account; specify absolute paths and inspect cron logs or Task Scheduler history. |
| The log says the page failed to load | The host may lack network access, DNS resolution may fail, or the target may reject or time out the request. | Check connectivity from the scheduled host and review captured status and scheduler logs. Do not treat a successful process launch as proof that the site loaded. |
| The image is blank or missing late content | The target may depend on asynchronous resources, newer browser behavior, authentication, or other features unsupported by this suspended project. | Validate the page in the installed PhantomJS version and test the relevant loading and access conditions. Do not assume the result will match a current browser. |
| Only part of a long page appears | The script may be rendering the viewport or a limited clip rectangle rather than the whole page. | Review the capture dimensions and clip settings against the guide; do not assume viewport capture means full-page capture. |
Or skip the browser setup
If you need recurring screenshots but do not want to maintain this legacy browser workflow, ScreenshotNeo provides a website screenshot API and MCP server. A single GET request can return an image or PDF. For example, this cURL request saves a WebP capture; see the ScreenshotNeo documentation for API 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 and consent banners before capture and removes known consent platforms, newsletter popups, and chat widgets; each cleanup step can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server offers 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 screenshots.
Sign up for ScreenshotNeo and get 1,000 free screenshots a month with no card.
Frequently Asked Questions
Does the PhantomJS script need to call phantom.exit()?
Yes. Call it after rendering or handling a failed page open so the PhantomJS process terminates instead of remaining active.
Best Value
Can I use the same schedule on Linux and Windows?
The capture command is the same in principle, but the scheduler configuration is platform-specific: cron on Linux and Task Scheduler or schtasks on Windows.
Does this example guarantee a full-page screenshot?
No. The capture guide documents viewport and clip-rectangle controls; choose and validate the dimensions you need.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchQuick 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.




