developer / Custom Cron
No results for ""
Custom Cron
Overview
You can hook into any of Demyx's cron intervals by placing a shell script in the corresponding file under /demyx/custom/cron/. Demyx executes these scripts at the end of each cron run.
Available Intervals
| File | Runs |
|---|---|
/demyx/custom/cron/minute.sh | Every minute |
/demyx/custom/cron/five-minute.sh | Every 5 minutes |
/demyx/custom/cron/hourly.sh | Every hour |
/demyx/custom/cron/six-hour.sh | Every 6 hours |
/demyx/custom/cron/daily.sh | Daily |
/demyx/custom/cron/weekly.sh | Weekly |
Example Scripts
All example scripts follow the same template:
#!/bin/bash
# Demyx custom cron — daily
set -euo pipefail
demyx_custom_daily() {
# Your custom logic here
echo "Running custom daily task"
}
demyx_custom_daily "$@"Use Cases
Off-site backup sync (daily)
#!/bin/bash
set -euo pipefail
demyx_custom_daily() {
# Sync backups to S3
aws s3 sync /demyx/backup/ s3://your-bucket/demyx-backups/ --delete
}
demyx_custom_daily "$@"Monitoring ping (five-minute)
#!/bin/bash
set -euo pipefail
demyx_custom_five_minute() {
# Ping a status page
curl -fsS "https://uptime.betterstack.com/api/v1/heartbeat/YOUR_TOKEN" > /dev/null
}
demyx_custom_five_minute "$@"Weekly cleanup (weekly)
#!/bin/bash
set -euo pipefail
demyx_custom_weekly() {
# Remove Docker build cache
docker builder prune -f
}
demyx_custom_weekly "$@"Activating
# Copy example scripts
cp /demyx/custom/example-cron/daily.sh /demyx/custom/cron/daily.sh
# Edit with your logic
nano /demyx/custom/cron/daily.sh
# Make executable
chmod +x /demyx/custom/cron/daily.shDebugging
View cron output including custom script results:
demyx log cronErrors in custom scripts are logged but don't stop the rest of the cron from running.