Automated script failing to execute

Hi: I'm running this scripts one after another manually to remove files for couple of months.

find /temp/DCS/NODE/COL1* -mtime +1 -exec rm -f {} \;
find /temp/DCS/ NODE /COL2* -mtime +1 -exec rm -f {} \;
find /temp/DCS/ NODE /COL3* -mtime +1 -exec rm -f {} \;

Now, I tried to automate it. I've created a file named cleanup_space.sh which contains above three lines and configured in crontab as below:

2 13 * * * "/users/scheduled_jobs/cleanup_space.sh" >/dev/null 2>&1

It was not working. I manually executed the file ./cleanup_space.sh and found that it's unable to delete files and showing error like Permission Denied each time it's trying to delete a file.

Can anyone tell me what went wrong?

Thanks!

Please specify your operating system and shell details.

Is that code the actual script ?

As it seems it has some extra spaces in last two find statements.
You will need to put the interpreter (magic cookie, shebang) as the first line of your script e.g #!/bin/bash for it to work in crontab.

Hope that helps
Regards
Peasant.

... and certainly there should not be spaces around NODE!

Yes, this is the original code. Please ignore the extra space, those are typo!
Linux ralprdappl001 2.6.32-504.8.1.el6.x86_64
Could you please write the entire code.
Thanks!

Instead us "writing the entire code" for you, why don't you provide exactly what you have with no "typo" and follow some of the suggestions already provided.
Also you can redirect stdout and stderr in cron to a file (instead of /dev/null) and see how YOU can debug it.
Do come back if you have something more specific than "write the entire code"...

Dear rain_man04

These forums are not your personal coding service.
We encourage users to think for themselves and show effort.

Please, control your urges and remain polite.
Insulting other members will get you nothing but sanctions.

Best regards
Peasant.

2 Likes

That said (above mods...)
You have errors, but havent shown us the messages, only your interpretation...
Furthermore you have not said who is running the script too, this can have great impact in what you are trying to do, we don't know on what kind of filesystem resides /temp/DCS/NODE etc...
You see, you have not given everything so you cannot expect other to guess in order to reply
So now before expecting anything more please add what is missing

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.