Question

Scheduled Tasks or Cronjobs with App Platform Worker

I’m looking to use App Platform for hosting some custom code. This is meant to be a scheduled type of task, so from what I understand, I’d want to set up a Worker component to run in the background. I have seen the docs and repo about the cron using Docker, over in the DigitalOcean-AppPlatform-Cron repo.

But I couldn’t find clarification on details regarding this Worker component. Is it a long running resource? I seem to be getting mixed answers as I search the internet, so I just wanted to be sure. I was thinking that if it was, then I could use something like node-cron within a script, and then have the Worker instance execute this script so that I can run some cron jobs. But I’d love to hear if this wouldn’t work.

Thanks in advance.


Submit an answer


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!

Sign In or Sign Up to Answer

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.

Bobby Iliev
Site Moderator
Site Moderator badge
June 5, 2024
Accepted Answer

Hi there,

Indeed, the Worker components are long running components. The main difference between a Worker component and a Web service component is that the Worker components are not exposed to the internet via HTTP.

The cronjob repo example that you are referring to here:

https://github.com/DO-Solutions/DigitalOcean-AppPlatform-Cron

This is going to be useful if you want to setup an HTTP endpoint that you can hit with that service on a specific schedule. However if you are looking to setup a CLI command instead, you would need to modify that example repo so that you actually deploy your code as well rather than just the cron and curl commands.

What you could do indeed is just fork that repository and extend it so that you could also include your app in there and use the cron service as well.

Let me know if this helps!

- Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more