Hey guys, im trying to run a script using cron, im using a crontab created by the user ashtanga, in the crontab i have

*/5 * * * *  /home/custom-django-projects/SiteMonitor/sender.py

in top of the script i have:


and the user ashtanga does have executable permission to the file, but cron is not running the script, its giving me the error:

/bin/sh: /home/custom-django-projects/SiteMonitor/sender.py: No such file or directory

so my question is, how can i get cron to run the script ?

  • What are the permissions on the file? Can you paste the output of ls -l? – Justin Ethier Jan 14 '11 at 14:40
  • -rwxr-xr-x 1 root root 431 Jan 7 19:42 sender.py – Paulo Jan 14 '11 at 14:45
  • 1
    what's readlink -f sender.py output. – xenoterracide Jan 14 '11 at 16:36
  • @ xenoterracide i ran it from root and this was the output /home/custom-django-apps/SiteMonitor/sender.py – Paulo Jan 14 '11 at 17:06
  • 1
    wow, i just noticed that i was trying to access the wrong directory by looking at the output from readlink -f sender.py and the error message, it now works !!, thanks a lot guys for taking the time to help, i really appreciate it :D – Paulo Jan 14 '11 at 20:32

The user does have permission as the permission is set to 755 The problem is that the user doesn't know of the environment variables needed. Try using bash instead and see if it picks them up then. Otherwise, set them up manually

Start troubleshooting by running the script using the /bin/sh shell. You should get the same error then.

| improve this answer | |
  • i tried exporting the SHELL variable and changing it to /bin/sh and then ran the script from the user ashtanga, and it didn't throw an error – Paulo Jan 14 '11 at 17:16
  • Did you try logging in as ashtanga running this command /bin/sh /home/custom-django-projects/SiteMonitor/sender.py ? – Luis Jan 14 '11 at 18:06
  • thanks, i just tried it and yes it gave me the same error, what do can i do so that it finds it – Paulo Jan 14 '11 at 20:09
  • If the permissions were the problem, the error would be Permission denied, even if it was some intermediate directory that was unreadable. – Gilles 'SO- stop being evil' Jan 15 '11 at 0:13

The user ashtanga doesn't have access to /home/custom-django-projects/SiteMonitor/sender.py. This looks like another user's home area?

Try running the script as ashtanga. It's always a good first step, before you add anything to cron.

It might be to do with your cron environment. Take a look at this Cron FAQ: It works from the command line but not in crontab

| improve this answer | |
  • thanks for the reply, as recommended by you i tried running the script as ashtanga, first like this: /home/custom-django-apps/SiteMonitor/sender.py , and then with a python in front of the directory, and both times were succesfull, but cron still cant run it – Paulo Jan 14 '11 at 16:11
  • try changing your cron to: */5 * * * * ls -ltr /home/custom-django-projects/SiteMonitor/sender.py 2>&1 > /tmp/test.log and see what it prints in the log – dogbane Jan 14 '11 at 16:33
  • nothin in the logs, all i got was a mail from cron with the following error ls: /home/custom-django-projects/SiteMonitor/sender.py: No such file or directory – Paulo Jan 14 '11 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.