[db2inst1@db2 ~]$ crontab -l

30 02 * * *  /bin/sh  /home/db2inst1/backup/backup.sh

[db2inst1@db2 ~]$ cat /home/db2inst1/backup/backup.sh

#!/bin/bash

bakdir=/home/db2inst1/backup

time1=`date  +"%Y-%m-%d %H:%M:%S"`

cd $bakdir

echo $time1 >> $bakdir/backup.log

/home/db2inst1/sqllib/bin/db2 backup db devdb104 online

if [ $? -eq 0 ];then

time2=`date  +"%Y-%m-%d %H:%M:%S"`

echo "the database backup is successfully completed at $time2" >> $bakdir/backup.log

else

echo "the database backup is failed" >> $bakdir/backup.log

fi

/bin/find /home/db2inst1/backup/ -type f -iname "devdb104.0.db2inst1.NODE0000.CATN0000*" -mtime +1 -exec rm -rf {} \;