Skip to main content
The 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

boolean
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:
1

Access Django Admin

Navigate to /admin/ and log in with your superuser account
2

Go to Periodic tasks

Click django_celery_beatPeriodic tasks
3

Edit task

Click on the task you want to modify (e.g., “cleanup_orphaned_photos”)
4

Change interval

Update the Interval field to your desired frequency
5

Save

Click Save - Celery Beat will pick up the changes automatically

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 in footycollect/collection/tasks.py:

Disabling tasks

To temporarily disable a task without deleting it:

Via Django Admin

  1. Go to django_celery_beatPeriodic tasks
  2. Click on the task
  3. Uncheck Enabled
  4. Click Save

Via management command

Troubleshooting

Verify Celery Beat is running:
Check Celery Beat logs for errors:
Verify the Celery worker is running:
Check worker logs:
The command uses update_or_create to prevent duplicates. If you see duplicates, manually delete them in Django Admin and re-run the command.

cleanup_orphaned_photos

Manual photo cleanup command

Celery Tasks

Learn about background task processing