时间定时同步
修改系统时间由三种方法:
一、修改时区
cp /etc/localtime /etc/localtime.bakln -svf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime#修改为中国的东八区vim /etc/sysconfig/clockZONE="Asia/Shanghai"UTC=falseARC=false#与时间服务器同步ntpdate ntp服务器的ip
二、配置新的时间
#日期设定date -s 2013/09/26#时间设定date -s "11:47:06"date -s "12:00:00 2013-12-06"....#date是显示的系统的OS时间#clock是显示的BIOS的时间#查看硬件的时间hwclock [-rw]-r 查看现有BIOS时间。默认为-r参数-w 将现在的linux系统时间写入BIOS中-s (systohc)将硬件时间调整为和目前的系统时间一半
三、时间自动同步
#1.开机自动网络校时cat /etc/rc.d/rc.local/usr/sbin/ntpdate -u 192.168.10.80#2.设置定时计划任务#yum install -y ntpdate (yum安装时间同步命令)crontab -e#加入内容*/5 * * * * root ntpdate 192.168.10.80 #每隔五分钟与时间服务器同步一次时间
日志定时清理
清理日志脚本
#!/bin/bashdate >>/home/wdhis/logs/catalina.outecho "del file start....." >> /home/wdhis/logs/catalina.outfind /home/wdhis/logs/*/*.log -mtime +14 -name "*.log" -exec rm -rf {} \; >> /home/wdhis/logs/catalina.outfind /home/wdhis/Server/dubbo-consumer/dubbo-emis-tomcat/logs/* -mtime +14 -name "*" -exec rm -rf {} \; >> /home/wdhis/logs/catalina.outfind /home/wdhis/Server/dubbo-consumer/dubbo-mmis-tomcat/logs/* -mtime +14 -name "*" -exec rm -rf {} \; >> /home/wdhis/logs/catalina.outfind /home/wdhis/Server/dubbo-consumer/dubbo-outpat-tomcat/logs/* -mtime +14 -name "*" -exec rm -rf {} \; >> /home/wdhis/logs/catalina.outfind /home/wdhis/Server/dubbo-consumer/dubbo-core-tomcat/logs/* -mtime +14 -name "*" -exec rm -rf {} \; >> /home/wdhis/logs/catalina.outfind /home/wdhis/Server/dubbo-consumer/dubbo-plugs-tomcat/logs/* -mtime +14 -name "*" -exec rm -rf {} \; >> /home/wdhis/logs/catalina.outecho " " > /home/wdhis/Server/dubbo-consumer/wdhis-emis-svr/logs/catalina.outecho " " > /home/wdhis/Server/dubbo-consumer/wdhis-mmis-svr/logs/catalina.outecho " " > /home/wdhis/Server/dubbo-consumer/wdhis-outpat-svr/logs/catalina.outecho " " > /home/wdhis/Server/dubbo-consumer/wdhis-core-svr/logs/catalina.outecho " " > /home/wdhis/Server/dubbo-consumer/wdhis-plugs-svr/logs/catalina.outecho "del file end" >> /home/wdhis/logs/catalina.outecho "del file provide nohup" >> /home/wdhis/logs/catalina.outecho " " > /home/wdhis/Server/dubbo-provider/wdhis-medicare-svr/nohup.outecho " " > /home/wdhis/Server/dubbo-provider/wdhis-outplugs-svr/nohup.outecho " " > /home/wdhis/Server/dubbo-provider/wdhis-payment-svr/nohup.outecho " " > /home/wdhis/Server/dubbo-provider/wdhis-report-svr/nohup.outecho "del file end nohup" >> /home/wdhis/logs/catalina.outdate >> /home/wdhis/logs/catalina.out#设置脚本执行权限chmod +x delete-logs.sh
将脚本加入定时任务
[root@admin wdhis]# crontab -ecrontab: installing new crontab[root@admin wdhis]# crontab -l#定时清理云HIS日志,在每隔十五天的0点* 0 */15 * * wdhis /home/wdhis/logs/delete_log.sh
