Operating System - HP-UX
1834934 Members
2970 Online
110071 Solutions
New Discussion

script help - removing files

 
SOLVED
Go to solution
Peter Gillis
Super Advisor

script help - removing files

I am trying to delete files older than 1 year old, every Sunday night (using cron to schedule). I have a log file being created that indicates files are being deleted - but I am also receiving a note via elm:
erase.imd2[2]: : Execute permission denied
erase.imd2[15]: : Execute permission denied
erase.imd2[2]: : Execute permission denied
erase.imd2[15]: : Execute permission denied
Why are these messages appearing?

the job erase.imd2 has perms= 777
the files to be deleted are perms=666
(should I change perm for files to be deleted to 766?)
op system=hp ux 11.00
machine d390
script file attached.
Can anyone help here...thanks
Maria.
6 REPLIES 6
Deepak Extross
Honored Contributor

Re: script help - removing files

Maria,

You need to have execute permissions on the DIRECTORIES which you "cd" to.
Hope this helps.

Peter Gillis
Super Advisor

Re: script help - removing files

Deepak,
thanks for your reply....all the directories have execute permission on them.
Maria.
Deepak Extross
Honored Contributor

Re: script help - removing files

Maria,

Does this problem occur only when you run the job thru cron? If so, it may be an environment issue or redirection issue.

Try doing a "set -x" at the top of the script to find out exactly which line of the script is cribbing.

-deepak.
Trond Haugen
Honored Contributor

Re: script help - removing files

To be more specific about Deepaks question; what user are running the cron job? And does that user have execute permission on the directory where the files are?

Another thing. Doing a 'cd' before the find&rm is generally dangerous. Should the cd fail the find will be done form the users HOME directory.

Regards,
Trond
Regards,
Trond Haugen
LinkedIn
Pierce Byrne_1
Frequent Advisor
Solution

Re: script help - removing files

Change the find to be -print.
After the find perform an ls -l on the file and send this to the log file.
Then run an rm on this file and check the error code after the rm.
Write the error code to the log.
This way if any file fails to be removed because of permissions you can check easily.
Reinhard Burger
Frequent Advisor

Re: script help - removing files

Dear maria

Maybe i'm asking a very silly question.
Does the account used to run the script within cron have WRITE permissions on the directories ?
If not then the permission to delete files in that directory is denied. ( Thats most often what i forget to check )

Reinhard
keep it simple