DBATips 2011-02-28
1.查询操作系统信息
1.linux 版本:uname
2.操作系统时间:
date +%y-%m-%d" "%H:%M:%S(11-01-12 02:08:02)
date +%Y-%m-%d" "%H:%M:%S(2011-01-12 02:08:47)
3.查看操作系统定时任务:
crontabFile=/var/spool/cron/tabs/root 也可以使用命令crontab -l 添加定时任务:
/usr/bin/killall cron
chmod u+w ${crontabFile}
echo "${CHECK_MINUTE} ${CHECK_HOUR} ${CHECK_DAY} ${CHECK_MONTH} ${CHECK_WEEK} ${CRON_SCRIPT}" >> ${crontabFile}
/usr/sbin/rccron restart
4.查看文本
cat root |grep -v "/usr/sbin/ntpdate"(去掉root包含/usr/sbin/ntpdate的行)
5.hwclock命令的使用
查看硬件时间
hwclock --show --utc
设置硬件时间为系统时间
hwclock --systohc --directisa
2.截取字符串
starttime="12\:02\:30";
hour=${starttime:0:2};
minute=${starttime:4:2};
second=${starttime:8:2};
echo "hour:${hour}";
echo "minute:${minute}";
echo "second:${second}";
运行结果:
hour:12 minute:02 second:30
3.添加多播路由
route add -net 224.0.0.0 netmask 240.0.0.0 dev eth53;
4.定时任务调度信息日志
/var/log/messages会打印定时任务的调度情况
5.循环遍历文件
for folder in `find $SERVER_HOME/conf -type d`
do
SERVER_CLASSPATH=$folder:$SERVER_CLASSPATH
done
6.常用
1.ping 172.16.128.8 -c 1 -q
2.从文件里面读取打包 BKP_ROLLBACK_ENTITIES="/home/oracle/.bash_profile ${gORACLE_HOME}/network/admin/listener.ora ${gORACLE_HOME}/network/admin/tnsnames.ora ${gORACLE_HOME}/dbs/init${oraSID}.ora ${gORACLE_HOME}/dbs/spfile${oraSID}.ora ${gORACLE_HOME}/dbs/orapw${oraSID}";
echo -e "${BKP_ROLLBACK_ENTITIES}" > "${BKP_ROLLBACK_GZTAR}.lst";
rm -vf "${BKP_ROLLBACK_GZTAR}" >> "${LOG_FILE}" 2>&1;
tar --ignore-failed-read -pczvf "${BKP_ROLLBACK_GZTAR}" -T "${BKP_ROLLBACK_GZTAR}.lst";
rm -rvf "${BKP_ROLLBACK_GZTAR}.lst";
3.登陆oracle su - "${oraInstUser}" -c "${CBB_CMD} sqlplus /nolog
su - "${oraInstUser}" -c "${CBB_CMD} lsnrctl start;"
su - ${oraInstUser} -c "${CBB_CMD} sqlplus -s ${oraSysUser}/${oraSysUserPwd} as sysdba
4.执行rman语句
${l_rmanLine}="allocate channel for maintenance type disk;\n change archivelog all crosscheck;\n release channel;" su - "${oraInstUser}" -c "${CBB_CMD} rman target /