About Logging the Output of a Management Command

If your management command returns a very long output, it makes sense to redirect it to a log file and read it in real time with the tail command:

(env)$ python manage.py my_command > ~/my_command.log 2>&1 &
(env)$ tail -f ~/my_command.log
  • > redirects the standard output to a file
  • 2>&1 redirects the error output to the same file
  • & runs the command in the background

This way you can inspect and analyze the output later.

Tips and Tricks Dev Ops Development Django 5.x Django 4.2 Django 3.2 Bash Zsh