Quote:
|
Originally Posted by noordeen
crontab we give this job. we have to servers one is working fine, other not working.
cronjob:
30 11 * * * find /{dirname} -name {filename}\*.log -atime +30 -exec rm -f {} \
Anybody know what reason not working, please tell we can try different way.
Thanks
|
What is "{dirname}" and "{filename}" supposed to be? If they are variables, then there is a "$" missing in front of both. Also, you have to set both variables somewhere.
What is the single trailing '\' supposed to do? There should be a ';' following to terminate the "rm" command.
You are sure that you want to have a file named "...*.log"? You are escaping the * with a backslash and don't have a forward slash there as directory separator.
What exactly does "not working" mean? cron sends emails to the owner if a cronjob produces some sort of output. Upon error, I would expect some output to occur. Check your email.
Alternatively, you could use something like this to get information on the exit status of find:
Code:
30 11 * * * find ... || echo "find failed with rc $?"
Or this to get a list of files that ought to be deleted:
Code:
find /{dirname} -name {filename}\*.log -atime +30 -print
p.s: As usual, you should first try your commands on a regular shell before putting them into crontab.