setup_beat_schedule command configures django-celery-beat periodic tasks with sensible default frequencies for automatic maintenance operations.
What it does
This command creates or updates periodic tasks in the database for:- Orphaned photo cleanup - Removes incomplete photos every 6 hours
- Full photo cleanup - Removes all orphaned photos every 7 days
- Old incomplete photo cleanup - Removes very old incomplete photos daily
Basic usage
Run this command once after deployment to configure automatic maintenance tasks.
Arguments and options
Preview what would be created/updated without making changes.Example:
Default periodic tasks
The command configures these tasks with default intervals:1. Cleanup incomplete photos (24h)
- Task:
collection.tasks.cleanup_orphaned_photos - Frequency: Every 6 hours
- Description: Removes photos from incomplete form submissions older than 24 hours
2. Cleanup all orphaned photos
- Task:
collection.tasks.cleanup_all_orphaned_photos - Frequency: Every 7 days
- Description: Comprehensive cleanup of all photo files not referenced in database
3. Cleanup old incomplete photos (168h)
- Task:
collection.tasks.cleanup_old_incomplete_photos - Frequency: Every 1 day
- Description: Removes very old incomplete photos (older than 7 days)
Example output
Customizing intervals
After running the command, you can adjust task intervals in Django Admin:When to run
After initial deployment
After updating FootyCollect
If new periodic tasks are added in a FootyCollect update:In Docker
Verifying tasks
Check configured tasks
Monitor Celery Beat
Celery Beat logs show when tasks are scheduled:Task implementation
The periodic tasks are defined infootycollect/collection/tasks.py:
Disabling tasks
To temporarily disable a task without deleting it:Via Django Admin
- Go to django_celery_beat → Periodic tasks
- Click on the task
- Uncheck Enabled
- Click Save
Via management command
Troubleshooting
Tasks not running
Tasks not running
Verify Celery Beat is running:Check Celery Beat logs for errors:
Tasks run but do nothing
Tasks run but do nothing
Verify the Celery worker is running:Check worker logs:
Duplicate tasks created
Duplicate tasks created
The command uses
update_or_create to prevent duplicates. If you see duplicates, manually delete them in Django Admin and re-run the command.