Forums

Script is not working at scheduled tasks

I am trying to run a script where i post a pic to my instagram account scheduled in a daily base. If i run the script via bash it runs perfectly. But running it through scheduled task it did not work. I changed the file (where the pics are stored) was located in a other folder to the script folder and gave the script the following path: script_directory = os.path.dirname(os.path.abspath(file)) which is obviously the path of the script. But it still doesn`t work please help!!!!

Are there any errors in the log file for the scheduled task? You can view the log by clicking the first button in the row of buttons next to it.

No there are no Errors. It seems that everything works fine. But nothing happened from the script (no Uploading of a pic).

This is the return code of the task: 2019-06-09 06:08:11 -- Completed task, took 45903.00 seconds, return code was 137.

That's a very long task run time; about 12 hours 45 minutes. Perhaps you could put logging in your script to see where it's spending all of that time? It looks like you're using Python 2.7, so if you put something like

print("{} about to do X".format(datetime.now()))
sys.stdout.flush()

...in various places in the code (don't forget to add the appropriate imports) then you'll be able to track what it's doing and hopefully narrow down the cause.

Is it possible to start via scheduled task a script (like Rest API or other) which start a bash console to start the bot?

No. Starting a console requires that you view it in a browser.