Cron Job
Learn how to easily create and manage scheduled tasks on ClawCloud Run.
Last updated
Was this helpful?
Learn how to easily create and manage scheduled tasks on ClawCloud Run.
Last updated
Was this helpful?
In ClawCloud Run, a Cron Job is used to create tasks that run at regular intervals. Unlike regular applications, Cron Jobs automatically trigger tasks based on a predefined schedule, making them ideal for maintenance routines or data processing scenarios.
Data Backup and Synchronization: Execute daily backups at midnight.
Scheduled Notifications: Send daily summary emails at a fixed time.
Batch Processing: Run data processing tasks every hour.
Scheduled Scaling: Perform scaling operations at set times.
Below is an example of how to configure a scheduled scaling task in ClawCloud Run.
For applications that experience predictable traffic fluctuations (such as during e-commerce promotions, gaming events, or office systems), scheduled scaling allows for precise resource management.
E-commerce Promotions: Scale up to 10 instances from 09:00 to 23:00 during peak promotional hours and scale down to 3 instances during off-peak hours.
Office Systems: Maintain 5 instances on weekdays from 08:00 to 20:00 and reduce to 1 instance during non-business hours.
Gaming Events: Scale up to 15 instances on weekends, while keeping 5 instances on weekdays.
Creating a Scheduled Task
Open the Cron Job section in the ClawCloud Run console.
Click the Add Cron Job button to create a new task.
Configuring Basic Parameters
Task Name: Provide an easily recognizable name, such as "nginx-scale".
Task Type: Choose the task type:
Scale APP Launchpad
: Scale application instances.
Access URL
: Access a specified URL.
Execute Command
: Run a custom command.
Cron Expression: Set the execution time using a Cron expression (based on Singapore Time).
App Name:
When selecting Scale APP Launchpad
, specify the target application for scaling.
Replica Count:
When using Scale APP Launchpad
, specify the desired number of instances.
Example Configuration:
This configuration means:
Cron Expression: 0 8 * * *
— The task runs daily at 8:00 AM Singapore Time.
Replica Count: The application instance count will be adjusted to 5.
For applications that need to be periodically paused (such as development environments or scheduled data processing tasks), you can combine two Cron Jobs to achieve automatic shutdown and startup.
Development Environment: Run only during weekdays from 09:00 to 18:00 and shut down outside these hours.
Data Processing Tasks: Start compute tasks between 02:00 and 04:00 daily.
Demo Systems: Operate only during customer viewing periods.
Creating a Shutdown Task
Click the Add Cron Job button to create the first task.
Configure the following parameters:
Click Deploy to save the configuration.
Creating a Startup Task
Click the Add Cron Job button again to create a second task.
Configure the following parameters:
Click Deploy to complete the configuration.
With this setup, the system will automatically:
Shut down instances every day at midnight, saving resources.
Restart the service every morning at 9:00, ensuring availability during working hours.
Operate continuously throughout the year without manual intervention.