Report this

What is the reason for this report?

How to schedule a Python web scraper to run every hour on a DigitalOcean Droplet?

Posted on June 11, 2026

I’m building a tool that collects ad data from public sources every hour. I’ve written the Python script but I’m not sure how to automate it on a DigitalOcean Droplet using cron jobs. What’s the best way to set this up reliably without it crashing?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there,

Cron is the right tool for this. Here is a basic setup:

First make sure your script runs cleanly from the command line, then open the crontab:

crontab -e

Add this to run every hour:

0 * * * * /usr/bin/python3 /path/to/your/script.py >> /var/log/scraper.log 2>&1

The >> /var/log/scraper.log 2>&1 part logs both output and errors so you can see what happened if something goes wrong.

A few things that make it more reliable:

Use absolute paths everywhere in your script, cron runs with a minimal environment and relative paths will break. If you are using a virtual environment, call the Python binary inside it directly:

0 * * * * /path/to/venv/bin/python /path/to/your/script.py >> /var/log/scraper.log 2>&1

Also add a check at the top of your script to make sure only one instance runs at a time, since if the scraper takes longer than an hour you will end up with overlapping runs.

DigitalOcean’s monitoring alerts are worth setting up too so you get notified if the Droplet goes down and your scraper stops running silently: https://docs.digitalocean.com/products/monitoring/

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

Dark mode is coming soon.