Forums

Scheduled Task not working

Is there something going on with scheduled tasks? I have an hourly script that has been running perfectly fine for months, but now just quits a few seconds after it is supposed to start. The really weird part is that it runs perfectly fine if I run it manually. Any ideas?

Does it give you any kind of error?

Could it have been the connection to the database? If so, you can try switching out your server address to boberhaus13.mysql.pythonanywhere-services.com ?

We haven't officially anounced it yet, but that's going to be our new addressing setup for mysql servers, and it may be more reliable than the old mysql.server system...

Well, it seems to be working now even though I didn't change anything. Not sure what happened, but I guess its all good now. Thanks!

This problem just started occurring again... Again theres no errors in the logs at all, just shows that it ran for 3 or 4 seconds and quit. Running it via the console works perfectly!

I am having a problem with the scheduled task: not running at all returning the following error code. They run fine when running from the bash command

 2014-09-24 09:27:04 -- Completed task, took 0.00 seconds, return code was 2.
Traceback (most recent call last):
File "/home/Cmaden/Jowhar.py", line 174, in <module>
get_article()
File "/home/Cmaden/Jowhar.py", line 99, in get_article
con = connections()
File "/home/Cmaden/Jowhar.py", line 27, in connections
cnx = mysql.connector.connect(user='*******',password='********',host='mysql.server',db='*********')
File "/usr/local/lib/python2.7/dist-packages/mysql/connector/__init__.py", line 44, in Connect
return MySQLConnection(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/mysql/connector/connection.py", line 110, in __init__
self.connect(**kwargs)
File "/usr/local/lib/python2.7/dist-packages/mysql/connector/connection.py", line 358, in connect
self._open_connection()
File "/usr/local/lib/python2.7/dist-packages/mysql/connector/connection.py", line 321, in _open_connection
self._socket.open_connection()
File "/usr/local/lib/python2.7/dist-packages/mysql/connector/network.py", line 395, in open_connection
errno=2003, values=(self.server_host, msg))
mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on 'mysql.server' (111)

Sorry about that. Our old way of providing connectivity from scheduled tasks to MySQL is having problems. We have a new way of doing it, which is technically in beta but actually seems to be more reliable -- if you use the host name your-username.mysql.pythonanywhere-services.com instead of mysql.server then it should work better and not have these intermittent errors. Let me know if that's not the case.

I made the fix and its been working so far. Thanks!

Hi Giles, What if you use a custom host name www.domainname.com for example what would be the host name ?

It doesn't matter what your host name is. That is the address for the MySQL server.

After our system update today, the username-based hostname is now the official way to connect to your MySQL database. The old mysql.server system still works, but is now deprecated.