Cron Jobs
Scheduled Jobs
Cron Jobs on Northflank
Cron Jobs use cases
- Automating system maintenance
- Update summary tables, for example daily traffic summaries
- Expire and erase cached data files in a certain interval
- Schedule long-running tasks to run from a command line script, for example encoding videos
Schedule
* * * * *
| | | | |
| | | | |_ day of week (0-6, 0 is Sunday)
| | | |___ month (1-12)
| | |_____ day of month (1-31)
| |_______ hour (0-23)
|_________ minute (0-59)
For example:
30 23 27 1 *
will execute at 23:30 on January 27th.30 23 * * 0
will execute every Sunday.
You can also use @yearly
, @annually
, @monthly
, @weekly
, @daily
, or @hourly
.
Platform Teams
Northflank makes it easier for infrastructure and platform teams to focus on levelling up the developer experience for their teams building great apps.
Common Cron Jobs questions among developers and platform teams:
Within a project, navigate to Jobs and create a job.
Once a cron job has been created, the section “Recent Job Runs” will provide details of the status of all the jobs that ran or failed.
You can choose to create a manual job. This will add the job to the pipeline but it won’t run until you click the Rub Job button.
Using the tag @hourly, the cron job will run every hour.
Under settings, the schedule for the job can be changed.
Health checks can be configured so that incoming traffic is only routed to available and healthy containers. Under health checks, you can configure the type, path, protocol and frequency with which the checks will run.
Once the cron job is created, under resources you can change the compute plan (memory and virtual CPU) to adapt to your needs.
Jobs and Cron Jobs on Kubernetes with Northflank
Northflank makes building scalable async job queues, background workers and event-based computation very simple.
The complex and challenging Kubernetes Job spec is immediately useable via the Northflank UI and API.
Immediately set up CI/CD flows, schedule workloads, and set up sensible retry, timeout, and parallel run options.
Run a job with a Docker CMD Override and image from DockerHub
await apiClient.start.job.run({
parameters: {
...
},
data: {
runtimeEnvironment: {
"VARIABLE_1": "abcdef",
"VARIABLE_2": "12345"
},
deployment: {
cmdOverride: "date",
external: {
imagePath: "alpine:latest"
}
}
}
});
Build and run a Git repository on a cron schedule
await apiClient.create.job.cron({
data: {
"backoffLimit": 0,
"runOnSourceChange": "never",
"activeDeadlineSeconds": 600,
"deployment": {
"cmdOverride": "nginx -g",
"vcs": {
"projectUrl": "https://github.com/northflank/gatsby-with-northflank",
"projectType": "github",
"accountLogin": "github-user",
"projectBranch": "master"
}
},
"buildSettings": {
"dockerfile": {
"buildEngine": "kaniko",
"useCache": false,
"dockerFilePath": "/Dockerfile",
"dockerWorkDir": "/"
}
},
"schedule": "30 8 * * *",
"concurrencyPolicy": "forbid"
}
});