DigitalOcean logo

How to run periodic jobs on DigitalOcean: Droplets, App Platform, Functions and Kubernetes

DigitalOcean has four built-in places to run a periodic job: cron or a systemd timer on a Droplet, a scheduled job component in App Platform, a scheduled trigger on a Function, and a CronJob on a DigitalOcean Kubernetes (DOKS) cluster. The fifth way keeps the schedule outside DigitalOcean and calls an HTTPS endpoint of your app. Which one fits depends on where your code already runs, how often the job has to fire and how long one run takes.

Everything below was checked against the DigitalOcean documentation and pricing pages, and against the Kubernetes and systemd documentation, in November 2026. Prices are as of November 2026.

Key takeaways

  • On a Droplet, cron reads the schedule in the system time zone and starts commands with a bare PATH. A systemd timer can name its own time zone and never starts a second copy while the first is still running.
  • An App Platform scheduled job is a job component with kind: SCHEDULED and a schedule block. It runs at most every 15 minutes and is billed only while it runs.
  • Scheduled triggers for Functions are still a private preview: three triggers at most, and none for function components inside App Platform.
  • On DOKS, give every CronJob a timeZone and concurrencyPolicy: Forbid, and make the job safe to run twice.

Which option fits your job?

Start from where the code lives. A job that needs files on a server belongs on that server, and a job that is part of an App Platform app belongs in that app. Move the schedule somewhere else only when its natural home can't do what you need, which usually comes down to the interval or the run time.

OptionShortest intervalTime zone of the scheduleCost (November 2026)
Cron on a Droplet1 minuteThe Droplet's system time zoneThe Droplet, from $4/month, whether or not anything runs
systemd timer on a DropletSeconds, if you lower AccuracySec=System zone, or one named in OnCalendar=The same Droplet
App Platform scheduled job15 minutestime_zone in the app specThe job's instance size, prorated per second, only while it runs (apps-s-1vcpu-0.5gb is priced at $5/month)
Functions scheduled trigger1 minute (the docs' own example)No time-zone setting90,000 GiB-seconds free per month, then $0.0000185 per GiB-second
CronJob on DOKS1 minutespec.timeZoneWorker nodes at Droplet prices; the standard control plane is free
External scheduler calling HTTPSWhatever the scheduler allowsThe scheduler's settingThe scheduler's plan; your app is already running

Two limits settle more cases than any other row: an App Platform job can't run more often than every 15 minutes, and a Function can't run longer than 15 minutes. A five-minute sync doesn't fit the first; a 40-minute export doesn't fit the second.

Diagram in four rows: cron or a systemd timer starts a process on the Droplet, checked in the systemd journal; an App Platform SCHEDULED job starts a new container that runs its run command and exits, listed under Activity, Jobs; a Functions scheduler trigger starts an activation of up to 15 minutes, read with doctl serverless activations logs; a DOKS CronJob creates a Job and a Pod on your worker nodes, read with kubectl logs.
Each option keeps the schedule in a different place, and each records its runs somewhere else.

Option 1: cron or a systemd timer on a Droplet

A Droplet is a Linux server, so it schedules work the Linux way. Choose it when the job needs local files or a specific binary, runs longer than 15 minutes, or has to fire every minute. The examples use Ubuntu; Debian behaves the same.

Add a crontab entry

  1. Check that cron is running. systemctl status cron should report it as active. If the unit doesn't exist, install it with sudo apt install cron. On AlmaLinux, Rocky Linux, CentOS Stream and Fedora the service is called crond.
  2. Check the clock the schedule will follow. timedatectl shows the system time zone. Cron on Ubuntu and Debian has no per-crontab time zone: a TZ= line changes the environment of your commands, not the time they start.
  3. Open the right user's crontab. crontab -e edits your own; sudo crontab -u deploy -e edits the one for the user deploy. The job runs with that user's permissions.
  4. Add the entry and save.
PATH=/usr/local/bin:/usr/bin:/bin
MAILTO=""
0 3 * * * /usr/bin/flock -n /tmp/nightly-report.lock /opt/app/bin/nightly-report >> /home/deploy/nightly-report.log 2>&1

Each part of that entry prevents a common failure:

  • PATH: Ubuntu's cron starts commands with PATH=/usr/bin:/bin and doesn't read .bashrc or .profile, so anything in /usr/local/bin is "command not found". Set PATH at the top, or use absolute paths (which php tells you the one to use).
  • flock -n skips a run while the previous one still holds the lock, so a slow night can't pile a second report on top of the first.
  • The redirect keeps stdout and stderr in a file you can read later. MAILTO="" stops cron from trying to mail the output.
  • Percent signs are special: cron turns an unescaped % into a newline. Write date +\%F, not date +%F.

To see whether cron started the job at all, read its journal with journalctl -u cron --since today. If you think in plain English rather than five fields, build the line with the crontab generator; the cron basics guide covers the syntax, and cron, time zones and daylight saving time covers what Ubuntu's cron does when the clocks change.

Or use a systemd timer

A systemd timer takes two small unit files instead of one crontab line. In return you get a time zone per schedule, protection against overlapping runs without flock, and logs filed under the job's own name. First the service, which says what to run:

# /etc/systemd/system/nightly-report.service
[Unit]
Description=Nightly report

[Service]
Type=oneshot
User=deploy
ExecStart=/opt/app/bin/nightly-report

Then the timer, which says when. By default a timer starts the service with the same name:

# /etc/systemd/system/nightly-report.timer
[Unit]
Description=Run the nightly report at 03:00 Berlin time

[Timer]
OnCalendar=*-*-* 03:00:00 Europe/Berlin
Persistent=true

[Install]
WantedBy=timers.target

Load and start it, then check when it will fire next:

sudo systemctl daemon-reload
sudo systemctl enable --now nightly-report.timer
systemctl list-timers nightly-report.timer
  • Time zone. The zone at the end of OnCalendar= is optional; without it the system zone applies. systemd-analyze calendar "*-*-* 03:00:00 Europe/Berlin" validates an expression and tells you when it will next elapse.
  • No overlap. If the service is still running when the timer elapses again, systemd leaves it running and doesn't start a second instance.
  • Accuracy. A timer fires within one minute of its time by default (AccuracySec=1min). Set AccuracySec=1us if the exact second matters.
  • Testing and logs. sudo systemctl start nightly-report.service runs the job now, and journalctl -u nightly-report.service shows every run.

Already have a crontab line? The cron to systemd timer converter writes both units for you.

Option 2: App Platform scheduled jobs

If the app already runs on App Platform, a scheduled job is the native answer: a job component, usually built from the same repository or image as the app, that App Platform starts on a cron schedule. Each run gets a fresh container that runs one command and exits. Jobs are not routable, so nothing can reach them over HTTP, and you pay for one only while it runs.

Add the job in the control panel

  1. Open the app and click Add components, then Create resources from source code.
  2. Select the Git repository or container image the job should use, usually the app's own, and click Next.
  3. In the Info section, click Edit and set Resource type to Job.
  4. In Deployment settings, set the run command to a command that does the work and exits, such as php artisan reports:nightly or node scripts/nightly-report.js.
  5. In Job trigger, click Edit, choose On a schedule and enter the cron expression in the Schedule field.
  6. Change the environment variables or instance size if the job needs it, then click Add resources. App Platform redeploys the app with the new job.

Watch out

Don't leave the run command empty. A job without one runs the runtime's default command, such as npm start for Node.js, which for most apps starts the web server instead of a task that finishes.

Or declare it in the app spec

If you manage the app as code, add the job to the app spec. The schedule goes in a schedule block with two keys: cron and time_zone, which takes a name from the tz database.

jobs:
  - name: nightly-report
    kind: SCHEDULED
    schedule:
      cron: "0 3 * * *"
      time_zone: Europe/Berlin
    github:
      repo: your-org/your-app
      branch: main
      deploy_on_push: true
    run_command: php artisan reports:nightly
    instance_size_slug: apps-s-1vcpu-0.5gb
    instance_count: 1
    envs:
      - key: DATABASE_URL
        scope: RUN_TIME
        value: ${db.DATABASE_URL}

${db.DATABASE_URL} is a bindable variable: App Platform fills in the connection string of the app's database component named db. Validate the spec, then apply it:

doctl apps spec validate app.yaml
doctl apps update <app-id> --spec app.yaml

What to know before you rely on it

  • 15 minutes is the floor. The docs give "minimum every 15 minutes" for the schedule. For a shorter interval, use a worker component that loops and sleeps, a Droplet, or an HTTPS call (option 5).
  • Two clocks. time_zone decides when the job starts. The clock inside the container is UTC unless you set a TZ environment variable (custom images also need the tzdata package), and App Platform always shows logs in UTC.
  • Environment variables. App-level variables reach every component, jobs included; a component-level variable with the same name wins. Tick Encrypt for secrets to keep them out of build, deployment and application logs.
  • Other kinds. The same kind field takes PRE_DEPLOY, POST_DEPLOY and FAILED_DEPLOY for jobs tied to deployments rather than the clock (in the control panel: Before every deploy, After every successful deploy, After every failed deploy). A job with no kind becomes POST_DEPLOY.
  • Checking runs. Open the app's Activity tab and click Jobs. From the terminal, doctl apps list-job-invocations <app-id> --job-name nightly-report lists the runs, and doctl apps logs <app-id> nightly-report --job-invocation <invocation-id> prints one run's log.

Option 3: scheduled triggers for DigitalOcean Functions

A Function can run on a schedule through a trigger. That suits short, stateless work such as refreshing a cache or syncing a few records between two APIs. Three limits decide whether it suits yours:

  • Scheduled triggers are in private preview, with a maximum of three triggers.
  • They aren't available for function components deployed through App Platform, only for functions in a standalone namespace.
  • A run can last 15 minutes at most, initialization included, with 128 MB to 1 GB of memory (256 MB by default).

Declare the trigger next to the function in project.yml. web: false keeps the function private, so only the trigger can start it; if you leave web out it defaults to true and the function gets a public URL.

packages:
  - name: reports
    functions:
      - name: nightly
        runtime: 'nodejs:default'
        web: false
        limits:
          timeout: 300000
        triggers:
          - name: nightly-3am
            sourceType: scheduler
            sourceDetails:
              cron: "0 3 * * *"
              withBody:
                mode: 'full'

timeout is in milliseconds, and withBody is the input the function receives on each scheduled run. Deploy with doctl serverless deploy . (doctl 1.82.0 or later); the output lists the deployed triggers. To read the last runs, use doctl serverless activations logs --function reports/nightly --limit 10.

You can also create a trigger in the control panel: open the namespace, then the function, then Source and Triggers, and click Create Trigger. The form checks the cron expression and spells it out in plain language as you type. Pick one method per function, though: a trigger made in the control panel for a function you deploy with doctl can be overwritten or deleted by the next doctl serverless deploy.

The cron syntax is stricter than Linux cron in two ways. Day of the week runs from 0 to 6 (or SUN to SAT), with no 7. And a step value has to divide the field's range evenly, so the hour field accepts only /1, /2, /3, /4, /6, /8 or /12. Neither project.yml nor the API has a time-zone field, and the docs don't say which zone the expression uses. Before you depend on a time of day, read the trigger from the Functions API: its scheduled_runs.next_run_at shows, in UTC, when it will actually fire.

Option 4: a CronJob on DigitalOcean Kubernetes

If you already run a DOKS cluster, use a Kubernetes CronJob. At each scheduled time the CronJob controller creates a Job, and the Job runs a Pod on your worker nodes. Nodes are billed like Droplets and the standard control plane is free, so the CronJob costs only the resources its Pod uses. It isn't worth creating a cluster for one job, though.

apiVersion: batch/v1
kind: CronJob
metadata:
  name: nightly-report
spec:
  schedule: "0 3 * * *"
  timeZone: "Europe/Berlin"
  concurrencyPolicy: Forbid
  startingDeadlineSeconds: 600
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: report
            image: registry.digitalocean.com/your-registry/report:1.4.0
            command: ["/app/bin/nightly-report"]
          restartPolicy: OnFailure

Apply it, then start one run by hand instead of waiting for 03:00:

kubectl apply -f nightly-report.yaml
kubectl create job report-test --from=cronjob/nightly-report
kubectl logs job/report-test
  • timeZone has been stable since Kubernetes 1.27, so every DOKS version supported in November 2026 (1.35 to 1.37) has it. Without it, the schedule follows the local zone of the kube-controller-manager, which runs on a control plane DigitalOcean manages for you. Putting CRON_TZ or TZ inside schedule is rejected with a validation error.
  • concurrencyPolicy defaults to Allow, which lets a slow run overlap the next one. Forbid skips the new run instead, and Replace stops the old run and starts the new one.
  • startingDeadlineSeconds skips a run that couldn't start within that many seconds of its time, instead of starting it late. Without it, a missed run has no deadline.
  • Twice or not at all. Kubernetes creates a Job "approximately once" per scheduled time, and says that in rare cases it creates two or none. Write the job so a second run does no harm.
  • Housekeeping. The CronJob's name can be at most 52 characters. By default it keeps the last 3 successful and the last failed Job for inspection. If the image is in DigitalOcean Container Registry, connect the registry first: open its Settings tab and edit DigitalOcean Kubernetes integration.

Option 5: call an HTTPS endpoint on a schedule

Sometimes the work already exists as a route in your running app, or none of the built-in schedulers fits. An App Platform job can't run every 5 minutes, and a Function trigger may be out of reach: you have no preview access, you need a fourth schedule, or the function is a component inside App Platform. In those cases, keep the schedule outside and have it call your app over HTTPS.

Two lanes. A scheduled job: the App Platform scheduler reads schedule.cron and time_zone, starts a fresh container that runs the run command and exits, and the container is then gone. An HTTPS call: an external scheduler sends a POST with an X-Cron-Secret header to a service that is already running, which checks the secret and answers 202 Accepted.
A job is a separate run in a new container. An HTTPS call runs inside the service you already have.

Because the endpoint can be reached from the internet, build it to refuse anything that isn't your scheduler:

  • Require a secret header. Accept POST only, compare a header such as X-Cron-Secret with a value from an encrypted environment variable, and answer 401 when it doesn't match. For a web function, set webSecure to a secret in project.yml; callers then have to send it in the X-Require-Whisk-Auth header.
  • Answer quickly. Start the work in the background or on a worker and return 202, so a long run isn't tied to one HTTP request.
  • Make it safe to repeat. Take a lock, such as a database row, so two calls can't run the same work at once.

With Cronit, that schedule is one job:

  1. Create a job with method POST and your endpoint, for example https://example.com/internal/cron/sync-orders. For a web function, doctl serverless functions get <package>/<function> --url prints its URL.
  2. Add the header X-Cron-Secret (or X-Require-Whisk-Auth for a web function) with your secret.
  3. Enter */5 * * * * and choose the time zone. The plain-English preview and the runs-per-month estimate show what you have scheduled.
  4. Send the test request before saving and check that it returns a 2xx status.

Each run then appears in the job's execution log with its status, and after repeated failures the job switches itself off instead of calling a broken endpoint forever. Compare the runs per month with the plans in the pricing section; the online cron job services roundup covers the alternatives.

FAQ

Can I run crontab inside an App Platform app instead?
Only if your run command starts the cron daemon itself, because App Platform does not start system-level cron the way a Linux server does. Every running instance would then fire the same schedule, so a scheduled job component is the safer choice.
What happens to runs missed while a Droplet was off?
Cron skips them: it only starts entries whose time comes while the daemon is running. A systemd timer with Persistent=true catches up instead, and runs the service once as soon as the timer is active again, usually right after boot.
Are Functions scheduled triggers billed?
Creating a trigger costs nothing during the private preview, and DigitalOcean notes that this may change. The invocations a trigger starts are billed like any others: in GiB-seconds, after the free monthly allowance.
Can a scheduled job read files my web service wrote?
No. A job is its own component with its own containers, and App Platform's local filesystem is temporary: data on it is lost after deployments and container replacements. Pass data through a Managed Database or Spaces Object Storage instead.

Run online cronjobs without server setup

Plan, schedule and run periodic tasks and scripts, from your browser with the first online cronjob platform.

Try for free