Home > front end >  Unable to run python script with shebang from /usr/local/bin
Unable to run python script with shebang from /usr/local/bin

Time:04-21

I have a python script saved to /usr/local/bin with

#!/usr/bin/python3

at the top and a chron job to run it 30 seconds after reboot and it's not working. When I try to run ./usr/local/bin/check_bios.py I get

bash: ./usr/local/bin/check_bios.py: No such file or directory

When I copy it to my home directory it works fine. When I execute it with

python /usr/bin/local/check_bios.py

it runs fine. I have

alias python="python3"

in my bashrc file, but I don't think that is what's causing this behavior. I tried adding /usr/bin/local to my path, but cron wouldn't use the path as far as I can think of. Does anyone know why the cron job won't execute and whay ./usr/bin/local/check_bios.py would throw an error? I'm on Linux Mint 20.2 if that helps at all.

CodePudding user response:

From the error:

bash: ./usr/local/bin/check_bios.py: No such file or directory

the cron job was looking for the check_bios.py script in the ./usr/local/bin path.

From that, I guessed that the cron job was:

? ? ? ? ? ./usr/local/bin/check_bios.py

where ? represents the time values (deliberately left them as ? since they weren't mentioned in the post, nor are they relevant to the issue).

I believe it should be:

? ? ? ? ? . /usr/local/bin/check_bios.py
  • Related