# How to Set Up Cloud Cronjobs on PandaStack (No Server Required)
Cronjobs are one of the most useful and most underrated features in any cloud platform. Whether you need to send a weekly digest, sync data from an external API, generate reports, or clean up old records, scheduled tasks are essential for almost every production application.
PandaStack's cronjob feature runs Docker containers on a schedule — no cron server to maintain, no VMs to keep alive, no manual scheduling.
How PandaStack Cronjobs Work
Each cronjob is a Docker container that runs on a schedule you define with a cron expression. The container executes, completes its task, and stops. You view the execution history, logs, and status from the dashboard.
This model is more reliable than a cron daemon on a VM (no host failures, no configuration drift) and cheaper (you only pay for compute during execution, not idle time).
Step 1: Create a Docker Image for Your Task
Your cronjob needs a Docker image that performs the task when run. Here is a simple example in Python:
# sync_data.py
import os
import requests
import psycopg2
def main():
# Fetch data from external API
response = requests.get(os.environ['API_URL'])
data = response.json()
# Write to database
conn = psycopg2.connect(os.environ['DATABASE_URL'])
cur = conn.cursor()
cur.execute("INSERT INTO sync_log (data, synced_at) VALUES (%s, NOW())", [str(data)])
conn.commit()
print(f"Synced {len(data)} records")
if __name__ == "__main__":
main()Dockerfile:
FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD ["python", "sync_data.py"]Step 2: Push to GitHub
Push your Dockerfile and application code to a GitHub repository. PandaStack will build the image on each deploy or trigger.
Step 3: Create a Cronjob via Dashboard
- 1Log in to [dashboard.pandastack.io](https://dashboard.pandastack.io)
- 2Click Cronjobs → New Cronjob
- 3Connect your GitHub repository (PandaStack builds the image for you)
— or enter a pre-built Docker image name
- 1Set the Schedule using a cron expression
Common cron expressions:
0 * * * * # Every hour, on the hour
0 0 * * * # Daily at midnight UTC
0 0 * * 1 # Weekly on Monday at midnight
*/15 * * * * # Every 15 minutes
0 8 * * * # Daily at 8am UTC
0 0 1 * * # First day of each month at midnight- 1Add Environment Variables:
- DATABASE_URL — your PandaStack managed database connection string
- API_URL — external API endpoint
- Any other secrets your task needs
- 1Click Create
Step 4: Create a Cronjob via CLI
npm install -g @pandastack/cli
panda login
panda cronjob create --name "daily-sync" --image your-org/sync-app:latest --schedule "0 0 * * *" --env DATABASE_URL=postgresql://...Step 5: Monitor Executions
In the Cronjobs dashboard, click your cronjob to see:
- Execution history: Each run with start time, duration, and status
- Logs: Full stdout/stderr output from the container
- Status: SUCCESS, FAILED, or RUNNING
Set up alerts for failed executions:
- Go to Monitoring → Add Alert
- Select Cronjob Failure as the alert type
- Add your Slack webhook or email address
Step 6: GitHub Integration for Auto-Rebuilds
If you connect a GitHub repository, PandaStack rebuilds the Docker image on every push. This means your cronjob always runs the latest version of your code — no manual image updates.
This is especially useful for tasks that query an evolving database schema or use an API that changes over time.
Step 7: Trigger a Manual Run
To test your cronjob without waiting for the schedule:
- 1Dashboard: Click your cronjob → Run Now
- 2CLI:
panda cronjob run --name daily-sync
Check the execution logs immediately after to verify the task completed successfully.
Full docs: [docs.pandastack.io](https://docs.pandastack.io).