Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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:

#!/usr/local/bin/python

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 ?

share|improve this question
    
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
add comment

2 Answers

up vote 0 down vote accepted

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.

share|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 Jan 15 '11 at 0:13
add comment

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

share|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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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