Forums

Django admin command fails to connect to DB while running as a scheduled task

Hi guys,

I've setup my project with virtualenvs. I have django 1.6. I need to run some periodical task that will check my models and does some actions for me so I've decided to write a django custom admin command. When I run the command itself from the console it works like a charm

./manage.py updateposts

Task started ... Task finished

To run this command as a scheduled task, I've added a bash script that runs this command for a specific environment

!/bin/bash

$HOME/.virtualenvs/noname/bin/python $HOME/noname/manage.py updateposts

Running this bash script from a console works as well.

The problem appears when I add a schedule task to run this bash script. It fails with the following error


django.db.utils.OperationalError: (2003, "Can't connect to MySQL server on 'mysql.server' (111)")

Any ideas? Am I missing something?

Thanks!

It looks like we had an outage with the mysql proxy server on the task server. I've given it a kick, see if things are better now?

Yes, now it works Thank you so much! Pythonanywhere rocks!

Hi guys,

Please check this issue one more time, seems it happens again

django.db.utils.OperationalError: (2003, "Can't connect to MySQL server on 'mysql.server' (111)")

Thanks

Thanks for the heads-up, I'll post updates in this thread.

Now it works, thank you guys!

Thanks for confirming!