4

I have the following crontab set up in a CentOS VPS:

SHELL=/bin/bash
HOME=/

* * * * * /root/ebay/findcheapitems.py

The script runs fine manually using:

python2.7 ebay/findcheapitems.py

It has been run through dos2unix for EOL conversion, has -rwxr-xr-x permissions, and first line of the file has:

#!/usr/local/bin python2.7

However I am getting mail every time the cron job attempts to run, saying:

/bin/bash: /root/ebay/findcheapitems.py: /usr/local/bin: bad interpreter: Permission denied

I've confirmed the location of python2.7 using 'which':

# which python2.7
/usr/local/bin/python2.7

I'm a linux beginner so I'm sure I'm missing something simple!

myeewyee
  • 747
  • 2
  • 9
  • 21
  • or see http://stackoverflow.com/questions/15351241/hadoop-usr-bin-env-python-no-such-file-or-directory . Good luck. – shellter Dec 19 '15 at 06:48

2 Answers2

7

You need to specify the filepath as one path, not as directory and filename:

#!/usr/local/bin/python2.7

Otherwise, the directory path is considered as an executable.

UPDATE As Kevin Guan suggested, you can also use /usr/bin/env instead of specifying the full path of the executable.

#!/usr/bin/env python2.7
falsetru
  • 357,413
  • 63
  • 732
  • 636
-1

Use

#!/usr/local/bin/python2.7

instead of #!/usr/local/bin python2.7

cola
  • 12,198
  • 36
  • 105
  • 165