Forums

scheduled tasks: return code 127

Since weeks I have scheduled tasks running daily & hourly without problems. Today I recognized that all of them return since 3 days a 127 error, indicating it cannot find the files (?):

2014-03-10 21:00:20 -- Completed task, took 2.00 seconds, return code was 127. bash: filename.py: command not found

Adding the absolute path to the scheduled tasks didn't help and the current working directory hasn't been changed (consciously) by me. What else could I try or did I overlook?

Sorry about that! We had a file server problem the other day, and it looks like the recovery process mis-assembled your sandbox on a scheduled task server. I've fixed things manually, and your scheduled tasks should work now.

I am having exactly the same problem. How can I fix it?

That's really weird. I did a thorough search yesterday to make sure that there was no-one else affected. and nothing came back. But I can see that the problem was affecting yours too.

I've forcibly rebuilt all sandboxes on the server that your tasks run on, and yours looks OK now. Sorry about that!

Your intervention fixed my problem immediately giles, thanks! Everything is back to normal now. Hope there aren't more users concerned.

Thanks giles, I'm up and running now.

Thanks for confirming, guys! I'm sure that I've got everyone fixed now. Of course, I was sure of that yesterday too, so I'll keep a close eye on the forums in case anyone else reports problems.

fixed

getting the same issue , can Anyone look into this " bash: home/PandeyAnupam/phn_pythonhost.py: No such file or directory

2017-06-14 04:31:20 -- Completed task, took 12.00 seconds, return code was 127.

"

home/PandeyAnupam/phn_pythonhost.py is probably not the path to your python script. It's more likely to be /home/PandeyAnupam/phn_pythonhost.py.

thanks Glenn :)

Hello, am receiving the same problem. bash: No such file or directory

2020-01-13 08:59:17 -- Completed task, took 7.00 seconds, return code was 127.

Make sure that the file that you're trying to run exists in your file storage.

Traceback (most recent call last): File "main.py", line 25, in <module> connection.sendmail(from_addr=my_email, to_addrs=birthday_person["email"], msg=f"subject: Birthday\n\n{contents}") File "/usr/lib/python3.8/smtplib.py", line 859, in sendmail msg = _fix_eols(msg).encode('ascii') UnicodeEncodeError: 'ascii' codec can't encode character '\u201c' in position 37: ordinal not in range(128)

2021-01-27 09:21:18 -- Completed task, took 11.59 seconds, return code was 1.

what is the problem???

You've got non ascii characters in the msg.

I'm getting /bin/bash: python: command not found from tasks that were running ok, since yesterday I can see issue

2022-01-28 20:44:06 -- Completed task, took 2.00 seconds, return code was 127.

Could you send us more details about the command you try to run as your task?

I was trying to run serval ways python3 slack_int2.py

python /home/ItamarB/slack_int3.py

another daily task that was running for a few weeks with no issues, started giving me this exit code from the 27/01/2022

2022-01-26 12:50:25 -- Completed task, took 13.35 seconds, return code was 0.

/bin/bash: python: command not found

2022-01-27 12:50:23 -- Completed task, took 10.67 seconds, return code was 127.

/bin/bash: python: command not found

2022-01-28 12:50:22 -- Completed task, took 9.98 seconds, return code was 127.

What happens if you run the same command in the bash console?

works.

Thanks for confirming that!

Hello,

I am testing a scheduled job with a very simple script. Unfortunately it return error 127. error message: /bin/bash: python: command not found

directory path: /home/NazaLearn/ytautomation/test.py

Can you please help? Thank you.

What is the command that you use in the scheduled task?

hi pafk,

I put the following command:

/home/NazaLearn/ytautomation/test.py

Please tell me what is wrong with it. Thank you.

In such case make sure that the script is executable (you can mark a file as an executable by running chmod +x <filename> in a Bash console) and that it has a "shebang" at the first line (something like: #!/bin/env python); alternatively you can prepend python to the command and skip those steps.

Hello pafk,

I did everything you said and still it gives me the error below. Does it has to do with the fact that Bash cannot find python interpreter? If I run it directly from the console it, works.

error message:

/bin/bash: python: command not found 2022-10-18 15:07:10 -- Completed task, took 5.73 seconds, return code was 127.

This is the command I inserted recently: python3.6 /home/NazaLearn/ytautomation/test.py

The code of test.py looks as follows:

"#!/bin/env python

from datetime import datetime

with open(datetime.now().strftime("%d-%m-%Y"), "w") as f: f.write('how you doing')"

Have you edited .bashrc or .profile in your home directory?

Hello fjl,

OMG! Thank you so much. I indeed overwrite file .profile_bash to test something! I refer ~/.bashrc in it and it now works. I only need to change the way the path works to make sure the file is saved in the right path.

Have a good day and thank you for the support! :)

/bin/bash: python: command not found

2022-11-14 18:58:06 -- Completed task, took 2.50 seconds, return code was 127.

I'm getting this error, how can i fix this

How does your task command look like? What happens when you run python command in your Bash console?

Hello, I am running a scheduled task with a script and getting Python3.10: command not found.

2023-03-17 03:02:07 -- Completed task, took 98.35 seconds, return code was 127.

Tried it a couple of times.

Command text is 'Python3.10 /home/LsVbadd07/neuroleg.py'

If I run the script manually it works properly.

The command should be rather python3.10 (lower case), than "Python3.10" (capital case).

Hello,

I'm also having trouble with a simple scheduled task.

When I run the command in the console it works fine. However, when I schedule it, the command fails.

The task log says: /bin/bash: python: command not found

2024-02-02 18:08:10 -- Completed task, took 4.01 seconds, return code was 127.

I've tried a number of ways, but the scheduled task is currently: cd /home/mkd/projects/birthday_wisher/ && python3 main.py

I'm certain I've ensured python is part of my $PATH.

Would you mind taking a look? Thanks!

Try deleting .bashrc and .profile and then start a new console to re-create the default files. Then see how that affects you task.

I can't solve the problem. The bot keeps crashing. When running tasks: Scheduled tasks, it gives an error:

bash: python3.10/home/ccriptobiz/bot/main.py: No such file or directory 2024-10-28 19:07:14 -- Completed task, took 7.01 seconds, return code was 127.

@ccriptobiz it looks like you're missing a space between python3.10 and /home..., thus the error.

Hi team, I also faced the same problem. Running a script in bash or directly in console works, but keeps failing in Tasks recently (starting from 25 October 2024). Even for a simple print('hello, world!') script.

The error message : /bin/bash: python: command not found (with return code 127)

Can you help to check on this please? If I need to add $PATH in my .bashrc or .profile, what should I put there? Thanks

Did you edit your ~/.bashrc or ~/.profile? Can you run python command in a Bash console?

@ brianca - We are discussing this over email, so we should just continue to do that.

My issue was solved. Thanks a lot @glenn for your help!

You're very welcome.

Just as a note so that it might help others in future. @brianca created a .bash_profile file that did not set the PATH environment variable (by running source ~/.bashrc which runs source /etc/bashrc to set the PATH), so PATH did not contain the necessary entries. When there is a .bash_profile file the normal .profile (which had the required PATH) is not executed when bash starts up in the scheduled task.

Hi! I'm running into a similar issue:

2024-12-03 14:02:21 -- Completed task, took 120.93 seconds, return code was 127. /bin/bash: python: command not found

It seems to have started on 2024-11-27. It's effecting all my tasks. When I manually run the code, it works.

Something in either your .bashrc or .bash_prifile is causing that. Check both of them. You can also just delete them and then start a new console and they will be re-created with the correct contents.