rm failing inside cron script

Posted by Nicholas on Super User See other posts from Super User or by Nicholas
Published on 2010-03-16T11:42:49Z Indexed on 2010/03/16 11:46 UTC
Read the original article Hit count: 469

Filed under:
|
|
|
|

I have a cron job calling a bash script which runs fine, except for one line inside it that is suppose to remove all fines in a directory. The result of this line is always 'no such file or directory' even though I have verified (many times) that there are files in that directory. The line in question is as simply:

rm /dir1/dir2/dir3/*

The script works fine when run manually in the terminal, so it must be something about how the cron is run. I've tried giving 'dir3' and all the files inside it every permission possible, so it shouldn't be a permission problem. (The directory and files are also owned by the user). I've tried specifing 'SHELL=/bin/bash' inside 'crontab'. There is no sticky bit set and there is no alias on the rm command.

Interestingly changing the 'rm' command to 'ls' gives the same negative result (unless you remove the trailing '*', and then that works).

What am I missing here?

© Super User or respective owner

Related posts about cron

Related posts about script