Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2007
    Posts
    4

    Unanswered: crontab setting not working

    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

  2. #2
    Join Date
    Aug 2006
    Location
    The Netherlands
    Posts
    248
    Is the cron daemon running? Check
    Code:
    ps -ef | grep cron | grep -v grep
    should return something like
    Code:
    root       575     1  0 Apr19 ?        00:00:00 crond
    Regards

  3. #3
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    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.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  4. #4
    Join Date
    Apr 2007
    Posts
    4
    Hi!
    Tyveleyn & Knut stolze,
    Thanks for your kind help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •