[root@db ~]# crontab -e
*/1 * * * * date >> /home/beaunet/date.txt >> 表示追加
表示每分钟 时间
1 0 * * * /root/scripts/product_top_review.sh > /dev/null2 > 表示覆盖
1 0 * * * /root/scripts/product_top_view.sh > /dev/null
1 0 * * * /root/scripts/product_top_recommend.sh > /dev/null
2 0 * * * /root/scripts/product_review_stat.sh > /dev/null
0 0 * * 6 /root/scripts/hair_top_display.sh > /dev/null
分 时 日 月 星期
crontab: no changes made to crontab
[root@db ~]# cd /root/scripts/
[root@db scripts]# ll
total 48
drwxr-xr-x 2 root root 4096 Dec 8 2008 00Backkup
-rw-r–r– 1 root root 449 Jun 27 2009 cron.log
-rwxr-xr-x 1 root root 98 Mar 4 2009 hair_top_display.sh
-rwxr-xr-x 1 root root 97 Jun 22 2009 member_online.sh
-rwxr-xr-x 1 root root 100 Jan 15 10:26 panasonic_1st.sh
-rwxr-xr-x 1 root root 100 Jan 15 10:26 panasonic_2nd.sh
-rwxr-xr-x 1 root root 97 Jan 14 17:37 panasonic.sh
-rwxr-xr-x 1 root root 104 Nov 4 11:26 product_review_stat.sh
-rwxr-xr-x 1 root root 106 Dec 4 2008 product_top_recommend.sh
-rwxr-xr-x 1 root root 103 Dec 2 2008 product_top_review.sh
-rwxr-xr-x 1 root root 101 Dec 3 2008 product_top_view.sh
-rwxr-xr-x 1 root root 671 Aug 27 2008 recommend.sh
[root@db scripts]# cat product_review_stat.sh
#!/bin/bash
su – oracle -c ‘sqlplus BEAU/QU6rqtv2@beau @/home/oracle/product/product_review_stat.sql;’
[root@db scripts]# cat /home/oracle/product/product_review_stat.sql
delete from product_review_stat;
commit;
insert into product_review_stat (id,product_id,review_count,recommend_avg)
select
product_review_stat_seq.nextval,
p.id product_id,
coalesce(crlp.total, 0) review_count,
coalesce(arlr.recommend_avg, 0) recommend_avg
from product p
inner join (select data_attribute_id,product_id,count(rowid) total
from review
where available_flg is not null
group by data_attribute_id,product_id) crlp on p.id = crlp.product_id
inner join (select data_attribute_id,product_id,avg(recommend_id) recommend_avg
from review
where recommend_id != 8
and recommend_id != 0
and available_flg is not null
group by data_attribute_id,product_id) arlr on p.id = arlr.product_id
and available_flg is not null
;
commit;
exit;
如果修改的product_review_stat.sh文件,就要重新载入
[root@test beaunet]# /etc/init.d/crond reload 表示重新载入