wtree Cloud

Jobs

Run commands in containers or scripts on servers on a cron schedule, with a log entry for every run.

Scheduled jobs run a command or script on a cron expression. Each run writes a log entry with its output and status.

Job types

TypeRunsInput
ApplicationInside an application containerA single command
ComposeInside a Compose service containerA single command
ServerOn the host of a remote serverA bash script
wtree Cloud ServerInside the wtree Cloud container, not on the hostA bash script

Application and Compose jobs use Docker exec, equivalent to:

docker exec -it <container_id> <command>

wtree Cloud Server jobs have access to the Docker socket, so they can manage containers and images with commands such as docker ps or docker image prune.

Create a job

Open the service and go to Settings › Scheduled jobs. For server jobs, open Scheduled jobs in the sidebar.

Click Add schedule and enter the command or script. For example, nginx -v prints the version inside an nginx container.

Set the schedule as a cron expression and save.

Verify

Open the job's logs after the first run and check the output and status.

Requirements

The target container must be running when the job fires. For Compose jobs, don't change the COMPOSE_PROJECT_NAME environment variable: wtree Cloud uses it to find the project.

Install any tools your server scripts use on the target server beforehand.

Examples

Clean up Docker data

Remove unused Docker data every 15 minutes (*/15 * * * *):

cleanup.sh
#!/bin/bash
docker system prune --force

Prune unused images

Remove unused images from a wtree Cloud Server job:

prune-images.sh
#!/bin/bash
docker image prune -af

Back up an unsupported database

Back up a database wtree Cloud doesn't support natively:

custom-backup.sh
#!/bin/bash
backup_date=$(date +%Y%m%d_%H%M%S)
backup_file="database_${backup_date}.backup"

container_name=$(docker ps --filter "name=clickhouse" --format "{{.Names}}")

docker exec -it $container_name clickhouse-client --query "BACKUP DATABASE mydb TO '/backups/$backup_file'"

# aws s3 cp /backups/$backup_file s3://your-bucket/backups/

Tips

  • Run the command by hand before you schedule it.
  • Handle errors in scripts so a failed step doesn't go unnoticed.
  • Watch resource use: frequent heavy jobs compete with your services.

Next steps

On this page