Created
February 6, 2017 21:15
-
-
Save archatas/50e4a19b9fee039c1abc404af8cb35f2 to your computer and use it in GitHub Desktop.
Django management commands scheduled and with logging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
SECONDS=0 | |
PROJECT_PATH=/home/myproject | |
CRON_LOG_FILE=${PROJECT_PATH}/logs/cleanup.log | |
echo "Cleaning up the database" > ${CRON_LOG_FILE} | |
date >> ${CRON_LOG_FILE} | |
cd ${PROJECT_PATH} | |
source bin/activate | |
cd project/myproject | |
python manage.py clearsessions --verbosity=2 --traceback >> ${CRON_LOG_FILE} 2>&1 | |
echo "Finished." >> ${CRON_LOG_FILE} | |
duration=$SECONDS | |
echo "$(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed." >> ${CRON_LOG_FILE} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MAILTO="" | |
00 01 * * * /home/myproject/scripts/cleanup.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment