Crontab Problem

I am trying to get a scheduled bash script to run. The line is: “*/30 * * * * /home/username/planet/”. I have tried a few other variations as well. I keep getting the error “/bin/sh: line 1: /home/username/planet/
: No such file or directory”. This works fine on the command line but I can’t get it work through crontab.

Any ideas? For testing, because of the problems, I set the permissions to 777 (bad I know). What is the needed permissions? Could this be the problem?

What is line 1? Cron environment has less PATH than command line. Not find all, php as example.

755 is good.

cd planet
python technews/config.ini

Is my script. Again, works fine on the command line. I am not sure what you where saying.

Define all paths I suggest.

cd /home/user/path/to/planet
/path/to/python /path/to/ /home/user/full/path/to/technews/config.ini

or use $HOME/… where you can.

Crontab knows few environment, like $PATH. Command line knows more, finds more.

I think that this problem is related to cron not finding the file rather than a problem with your script. Are you sure that you’re giving the correct path to the script, remembering the fact that it’s CasESenSiTivE?

–Matttail - personal website

Like I have said before. I can run the script on the command line. As soon as I put in in Cron, it errors out.

Remember that cron jobs don’t by default run with the same shell environment as a logged in user. It may be necessary to “source” your “.profile” and/or “.bashrc” or whatever shell environment is necessary… BUT

The correct way to do it is to find out what is necessary and only include the paths you need or as an example showed above, explicitly state your files. The reason is to minimize the chance of an exploit being introduced along your path.

Hope this helps.


After contacting support, they said that the end-of-line character was wrong. It is working again. Thanks for the help guys.

Of course line termination could also be an issue… (grin) It certainly explains why the error was on line #1.

Wholly - IS NOT MY PROMO CODE. Even worse, I don’t get any credit for it. Use WhollyMindless for full credit. I’m really disappointed in someone.