Cron Jobs
Each running App has the ability to run a cron job. Cron Job is a powerful tool for scheduling tasks to run automatically at predefined times or intervals. This allows you to automate repetitive tasks and ensure they are executed consistently without manual intervention.
Cron Jobs leverage the concept of cron expressions, which define schedules using a specific syntax. These expressions specify the minute, hour, day of month, month, and day of week when a job should run. Hostless provides a user interface and functionalities to manage Cron Jobs for your applications.
This documentation explains the concept of cron jobs within the Hostless provider application.
- Creating a cron job(s)
- Accessing cron job(s)
- Modifying a cron job(s)
- Pausing a cron job(s)
- Trigger a cron job(s)
Creating a cron job
Hostless offers a general approach to create cron jobs depending on your programming language and preferences. Here's a general overview:
- Navigate to the
Cron Jobs
tab on the app view - Click on
Create New Job
- Assuming the code for your cron job already exist in your linked repo, define you command to run the cron job
- Define a cron expression e.g */5 * * * *
- Choose your preferred timezone
- You can adjust the vCPUs and memory depending on the intensity of the the job or task
- Click on
Create Cron Job
Please note: Some programming languages may require more memory and vCPUs to run/start compared to the default configurations. If your application does not start, you can still edit this configurations
Accessing a Cron Job
Hostless provides a user interface for managing and monitoring your cron jobs. You can access this interface to view:
- List of Cron Jobs: This view displays a comprehensive list of all currently registered cron jobs within your Hostless app environment. It shows information like Job id, command to start the job, cron expression, status, last run time, when it was created and options to view, edit, pause or trigger a job
-
Viewing Previous Job Runs: Hostless allows you to view information about previous executions of your Cron Jobs. This can be helpful for troubleshooting potential issues or monitoring the job's performance over time. You will be able to see details like:
- Execution Time: The exact timestamp of when the job was last run.
- Status: Whether the job execution was successful, failed or still running.
- Logs: Access logs generated during the job's execution, potentially including standard output and error messages from the job's command or script.
Modifying a Cron Job
Hostless allows you to modify existing Cron Jobs to update their configuration. This can involve:
- Changing the Cron Expression: Modify the schedule of the job by adjusting the cron expression.
- Updating the Job Command: Edit the command or script the job executes.
- Updating the timezone, vCPUs and memory allocation
Pausing a Cron Job
You can also pause a Cron Job to temporarily prevent it from running according to its schedule. This can be useful for maintenance purposes or when you want to disable a job for a specific period.
Trigger a Cron Job
Hostless offers a functionality to manually trigger a Cron Job to run immediately, bypassing its scheduled execution time. This can be useful for testing purposes or running the job on demand.
Example project: