Scheduled Tasks Runs without Error but does not produce any output


I have setup a scheduled task to run daily.

The task uses the Django Commands as I found this was the preferred method to use with PythonAnywhere.

The tasks produces no errors but I don't get any output. 2022-06-16 22:56:13 -- Completed task, took 9.13 seconds, return code was 0.

I have tried uses Print() to debug areas of the code but I cannot produce any output in either the error or server logs. Even after trying print(date_today, file=sys.stderr).

I have set the path on the Scheduled Task as: (Not sure if this is correct but seems to be the only way I can get it to run without errors.)

workon advancementvenv && python3.8 /home/vicinstofsport/advancement_series/ shell < /home/vicinstofsport/advancement_series/advancement/management/commands/

I have tried setting the path as below but then it gets an error when I try to import from the file. Traceback (most recent call last): File "/home/vicinstofsport/advancement_series/advancement/management/commands/", line 3, in <module> from advancement.models import Bookings ModuleNotFoundError: No module named 'advancement'

2022-06-17 03:41:22 -- Completed task, took 14.76 seconds, return code was 1.

Any ideas on how I can get this working? It all works fine locally if I use the command py scheduled_task

Thanks in advance for any help.

Where do you get that traceback? Have you tried to run your management command in the bash console?

The traceback was from the "View Task Log" on the Schedule Task. If I run the management command from the bash console it works using "(advancementvenv) 00:25 ~/advancement_series (master)$ python schedule_task"

It's working from the console because your working directory is ~/advancement_series Add cd /home/vicinstofsport/advancement_series && to the start of your task command.

Perfect thanks Glenn, that worked. Appreciate the help.