jobs

I am running this script below as a cron job for user root. In fact I set this job early last week and expected it to delete archive logs older than 7 days, but doesn't work - just displays the echo messages and no error. Can somebody advise me the probable causes ??

DAY_AFTER=7; export DAY_AFTER
DELETE_FROM_DIR=/u05/oracle/oradata/TOLL2/archlog; export DELETE_FROM_DIR
date
echo '~'
echo 'About to delete archive logs...'
echo '
~'
find $DELETE_FROM_DIR -name "*.*" -mtime +$DAY_AFTER -exec rm {} \;
echo '~'
echo 'Process Complete.'
echo '
~'
date

You can do this :

  • put the absolute path of the find command : /usr/bin/find
  • put the "#!/bin/sh -v" in the first line of your script to verbose a command execution.
  • direct the output of your script to a file in the crontab : your_script > /tmp/script.log 2>&1

Check the result ...

Witt