tnt4913 发表于 2007-10-29 17:35

如何配置CRON让系统每天临晨4点自动执行SELECT服务啊?

有关CRON的配置问题


前阵子在坛子里发帖问用SELECT语句取得当前日期的问题,在liaosnet大哥的热心帮助下以成功调试过去,代码已经写到如下阶段,我想配置一下CRON服务,让系统每天凌晨4点自动运行,怎么弄啊?哪位大哥能帮下小弟啊?
dbaccess omc_db<<!
unload to "/home/omcadmin/yerui/ttt/pm.txt"
select*
where (*)
and (*)
and (*)
and (*)
(bss_datetimes.date_and_time>=to_char(current year to day - interval(1) day to day,"%Y-%m-%d")||" 09:00")
and (bss_datetimes.date_and_time<=to_char(current year to day - interval(1) day to day,"%Y-%m-%d")||" 10:00")
order by *,*

ivhb 发表于 2007-10-29 17:52

去shell问,保准有人告诉你

liaosnet 发表于 2007-10-30 09:14

将你的这个脚本保存为shell
eg: crontabl.sh
#!/bin/sh
dbaccess omc_db<<!
unload to "/home/omcadmin/yerui/ttt/pm.txt"
select*
where (*)
and (*)
and (*)
and (*)
(bss_datetimes.date_and_time>=to_char(current year to day - interval(1) day to day,"%Y-%m-%d")||" 09:00")
and (bss_datetimes.date_and_time<=to_char(current year to day - interval(1) day to day,"%Y-%m-%d")||" 10:00")
order by *,* ;
!

然后root用户,在crontab中增加一行.
# crontab -e
* 4 * * *su - informix -c "<完整目录>/crontab.sh &" >/dev/null 2>&1

[ 本帖最后由 liaosnet 于 2007-10-30 09:15 编辑 ]
页: [1]
查看完整版本: 如何配置CRON让系统每天临晨4点自动执行SELECT服务啊?