Scheduled Jobs Without Running Your Own Server
At some point almost every app needs to do something when nobody is actively using it. Send a weekly email, refresh some data, clean up old records or generate a report every Monday morning.
My first instinct used to be that this meant I needed a server running permanently somewhere. In practice, that is often unnecessary.
The useful mental model is that the job itself does not need to know anything about time. It can simply be a normal function or endpoint that runs once and exits. The schedule lives somewhere else.
For example, if I want to send a weekly summary, I can create an endpoint that calculates the numbers and sends the email. Then a scheduler calls that endpoint every Monday.
The application logic stays simple:
scheduler → protected endpoint → database → email
The important part is protecting the endpoint. If visiting a URL triggers an administrative job, I obviously do not want anyone on the internet to be able to run it. A shared secret or another server-side authentication mechanism can make sure the request really came from the scheduler.
This also makes testing easier. I can run the job manually without waiting until Monday and verify that the actual logic works independently from the scheduling infrastructure.
The lesson for me was that “cron job” and “server process running forever” are not the same thing anymore. With serverless platforms, a scheduled task can simply wake up, do its work and disappear again.
Topics
