Crontab Permissions Issue with Python

I have a cron on a Linux server that isn't executing properly.
CRON (with specific info replaced):

MAILTO=emailaddress@server.com
*/2 * * * * python /data/site/cron.py

OUTPUT:

python: can't open file '/data/site/cron.py
': [Errno 2] No such file or directory

Additional info

  • The python path is correct
  • Cron is a root cron
  • Cron format is correct and the cron runs every 2 minutes as specified, but gets the error 'cannot open file'
  • the command "python /data/site/cron.py" runs fine in the shell
  • SELinux is turned off
  • File permissions for cron.py are 777

I've tried everything that I can think of. Any ideas why the cron does not see the file?

# cat /etc/cron.d/cron.deny
daemon
bin
smtp
nuucp
listen
nobody
noaccess

Is it trying to open the filename with an appended newline? Note the closing quote around the filename in the error message begins on a second line.

Regards and welcome to the forum,
Alister

cron.deny was empty.

It was the new line character issue.

I used crontab -e and pasted it in manually instead of reading from a text file (crontab cron.txt) and it runs.

I put the linebreak in on purpose (to avoid EOF error) Maybe it was saved with the wrong encoding or had /r/n or something.

Anyway, it's working like a champ now!

Thanks for your help, this forum is awesome!