关于history的时间问题
[
|
2010/08/30 13:33]
|
2010/08/30 13:33]
history是bash的内建命令,在bash3.0之后的history命令可以记录命令的执行时间。可以简单的用于用户审计。看一下帮助信息:
kook-sles10364:~ # help history
history: history [-c] [-d offset] [n] or history -awrn [filename] or history -ps arg [arg...]
Display the history list with line numbers. Lines listed with
with a `*' have been modified. Argument of N says to list only
the last N lines. The `-c' option causes the history list to be
cleared by deleting all of the entries. The `-d' option deletes
the history entry at offset OFFSET. The `-w' option writes out the
current history to the history file; `-r' means to read the file and
append the contents to the history list instead. `-a' means
to append history lines from this session to the history file.
Argument `-n' means to read all history lines not already read
from the history file and append them to the history list.
If FILENAME is given, then that is used as the history file else
if $HISTFILE has a value, that is used, else ~/.bash_history.
If the -s option is supplied, the non-option ARGs are appended to
the history list as a single entry. The -p option means to perform
history expansion on each ARG and display the result, without storing
anything in the history list.
If the $HISTTIMEFORMAT variable is set and not null, its value is used
as a format string for strftime(3) to print the time stamp associated
with each displayed history entry. No time stamps are printed otherwise.
看到变量$HISTTIMEFORMAT了吧。加入到/etc/profile里面即可。
export HISTTIMEFORMAT="%Y/%m/%d-%H:%M:%S "
显示类似输出如下:
994 2010/08/30-13:30:50 history
995 2010/08/30-13:31:10 vi /etc/profile
996 2010/08/30-13:31:23 exit
实际在.bash_history里面是这样显示的。首先是时间,然后是命令。
#1283146270
vi /etc/profile
#1283146283
exit
上面的是Unix Time指的是1970-1-1以秒来计时。用以下方式date可以来换算。
kook-sles10364:~ # date -s @1283146283
Mon Aug 30 13:31:23 CST 2010
可以获取当期的Unix Time
kook-sles10364:~ # date +%s ; date
1283146567
Mon Aug 30 13:36:07 CST 2010
如上,具体什么时间操作什么,就可以留下一个记录了。建议将命令的保留行数也加大。
kook-sles10364:~ # help history
history: history [-c] [-d offset] [n] or history -awrn [filename] or history -ps arg [arg...]
Display the history list with line numbers. Lines listed with
with a `*' have been modified. Argument of N says to list only
the last N lines. The `-c' option causes the history list to be
cleared by deleting all of the entries. The `-d' option deletes
the history entry at offset OFFSET. The `-w' option writes out the
current history to the history file; `-r' means to read the file and
append the contents to the history list instead. `-a' means
to append history lines from this session to the history file.
Argument `-n' means to read all history lines not already read
from the history file and append them to the history list.
If FILENAME is given, then that is used as the history file else
if $HISTFILE has a value, that is used, else ~/.bash_history.
If the -s option is supplied, the non-option ARGs are appended to
the history list as a single entry. The -p option means to perform
history expansion on each ARG and display the result, without storing
anything in the history list.
If the $HISTTIMEFORMAT variable is set and not null, its value is used
as a format string for strftime(3) to print the time stamp associated
with each displayed history entry. No time stamps are printed otherwise.
看到变量$HISTTIMEFORMAT了吧。加入到/etc/profile里面即可。
export HISTTIMEFORMAT="%Y/%m/%d-%H:%M:%S "
显示类似输出如下:
994 2010/08/30-13:30:50 history
995 2010/08/30-13:31:10 vi /etc/profile
996 2010/08/30-13:31:23 exit
实际在.bash_history里面是这样显示的。首先是时间,然后是命令。
#1283146270
vi /etc/profile
#1283146283
exit
上面的是Unix Time指的是1970-1-1以秒来计时。用以下方式date可以来换算。
kook-sles10364:~ # date -s @1283146283
Mon Aug 30 13:31:23 CST 2010
可以获取当期的Unix Time
kook-sles10364:~ # date +%s ; date
1283146567
Mon Aug 30 13:36:07 CST 2010
如上,具体什么时间操作什么,就可以留下一个记录了。建议将命令的保留行数也加大。
关于SuSE启动文件rc.local
[
|
2010/07/30 15:38]
|
2010/07/30 15:38]
rc.local是Redhat系里面关于进入系统后,最后一个执行的文件。而在SuSE里面不存在这个文件。
对于SuSE来讲,启动过程中几个自己控制的文件如下:
1:boot.local
这个是系统启动完所有的boot.services之后执行的脚本。详见文件注释
# /etc/rc.d/boot.local
# Here you should add things, that should happen directly after booting
# before we're going to the first run level.
#
2:before.local 和 after.local
这个是由/etc/init.d/rc里面来控制的,发生在切换运行级别之前和之后。
结论:如果你想进入系统最后执行的一个变量和参数。应该写入文件after.local
对于SuSE来讲,启动过程中几个自己控制的文件如下:
1:boot.local
这个是系统启动完所有的boot.services之后执行的脚本。详见文件注释
# /etc/rc.d/boot.local
# Here you should add things, that should happen directly after booting
# before we're going to the first run level.
#
2:before.local 和 after.local
这个是由/etc/init.d/rc里面来控制的,发生在切换运行级别之前和之后。
结论:如果你想进入系统最后执行的一个变量和参数。应该写入文件after.local
应用wvdial进行电信天翼-Huawei-EC620拨号
[
|
2010/07/16 12:35]
|
2010/07/16 12:35]
应用wvdial进行电信天翼-Huawei-EC1260拨号
操作系统:
SLED11 SP1 X86_64
1:确认已经安装软件包
wvdial
rpm -qi wvdial
如果未安装,请安装zypper in wvdial
2:查询华为设备并创建配置文件
执行命令wvdialconf,最终提示你创建
KOOK-SLED11164:~ # wvdialconf
Editing `/etc/wvdial.conf'.
Scanning your serial ports for a modem.
ttyS0<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud
ttyS0<*1>: ATQ0 V1 E1 -- failed with 9600 baud, next try: 115200 baud
ttyS0<*1>: ATQ0 V1 E1 -- and failed too at 115200, giving up.
Modem Port Scan<*1>: S1 S2 S3 S4 S5 S6 S7
WvModem<*1>: Cannot get information for serial port.
ttyUSB0<*1>: ATQ0 V1 E1 -- OK
ttyUSB0<*1>: ATQ0 V1 E1 Z -- OK
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 -- OK
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 -- OK
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
ttyUSB0<*1>: Modem Identifier: ATI -- Manufacturer: +GMI: HUAWEI TECHNOLOGIES CO., LTD
ttyUSB0<*1>: Speed 9600: AT -- OK
ttyUSB0<*1>: Max speed is 9600; that should be safe.
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
WvModem<*1>: Cannot get information for serial port.
ttyUSB1<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud
ttyUSB1<*1>: ATQ0 V1 E1 -- failed with 9600 baud, next try: 9600 baud
ttyUSB1<*1>: ATQ0 V1 E1 -- and failed too at 115200, giving up.
WvModem<*1>: Cannot get information for serial port.
ttyUSB2<*1>: ATQ0 V1 E1 -- OK
ttyUSB2<*1>: ATQ0 V1 E1 Z -- OK
ttyUSB2<*1>: ATQ0 V1 E1 S0=0 -- OK
ttyUSB2<*1>: ATQ0 V1 E1 S0=0 &C1 -- OK
ttyUSB2<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK
ttyUSB2<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
ttyUSB2<*1>: Modem Identifier: ATI -- Manufacturer: +GMI: HUAWEI TECHNOLOGIES CO., LTD
ttyUSB2<*1>: Speed 9600: AT -- OK
ttyUSB2<*1>: Max speed is 9600; that should be safe.
ttyUSB2<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
Found a modem on /dev/ttyUSB0.
Modem configuration written to /etc/wvdial.conf.
ttyUSB0<Info>: Speed 9600; init "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"
ttyUSB2<Info>: Speed 9600; init "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"
3:确认设备名,替换配置文件
将下面的配置文件改为你找到的设备名,如上面的/dev/ttyUSB0
替换掉
Modem = /dev/ttyUSB0
即可
KOOK-SLED11164:~ # cat /etc/wvdial.conf
[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = Analog Modem
ISDN = 0
New PPPD = yes
Phone = #777
Modem = /dev/ttyUSB0
Username = vnet.mobi
Password = ctnet@mycdma.cn
Baud = 9600
[Dialer cdma1x]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = Analog Modem
ISDN = 0
New PPPD = yes
Phone = #777
Modem = /dev/ttyUSB0
Username = CARD
Password = CARD
Baud = 460800
4: 拨号后,放入后台
KOOK-SLED11164:~ # wvdial & disown
操作系统:
SLED11 SP1 X86_64
1:确认已经安装软件包
wvdial
rpm -qi wvdial
如果未安装,请安装zypper in wvdial
2:查询华为设备并创建配置文件
执行命令wvdialconf,最终提示你创建
KOOK-SLED11164:~ # wvdialconf
Editing `/etc/wvdial.conf'.
Scanning your serial ports for a modem.
ttyS0<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud
ttyS0<*1>: ATQ0 V1 E1 -- failed with 9600 baud, next try: 115200 baud
ttyS0<*1>: ATQ0 V1 E1 -- and failed too at 115200, giving up.
Modem Port Scan<*1>: S1 S2 S3 S4 S5 S6 S7
WvModem<*1>: Cannot get information for serial port.
ttyUSB0<*1>: ATQ0 V1 E1 -- OK
ttyUSB0<*1>: ATQ0 V1 E1 Z -- OK
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 -- OK
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 -- OK
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
ttyUSB0<*1>: Modem Identifier: ATI -- Manufacturer: +GMI: HUAWEI TECHNOLOGIES CO., LTD
ttyUSB0<*1>: Speed 9600: AT -- OK
ttyUSB0<*1>: Max speed is 9600; that should be safe.
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
WvModem<*1>: Cannot get information for serial port.
ttyUSB1<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud
ttyUSB1<*1>: ATQ0 V1 E1 -- failed with 9600 baud, next try: 9600 baud
ttyUSB1<*1>: ATQ0 V1 E1 -- and failed too at 115200, giving up.
WvModem<*1>: Cannot get information for serial port.
ttyUSB2<*1>: ATQ0 V1 E1 -- OK
ttyUSB2<*1>: ATQ0 V1 E1 Z -- OK
ttyUSB2<*1>: ATQ0 V1 E1 S0=0 -- OK
ttyUSB2<*1>: ATQ0 V1 E1 S0=0 &C1 -- OK
ttyUSB2<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK
ttyUSB2<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
ttyUSB2<*1>: Modem Identifier: ATI -- Manufacturer: +GMI: HUAWEI TECHNOLOGIES CO., LTD
ttyUSB2<*1>: Speed 9600: AT -- OK
ttyUSB2<*1>: Max speed is 9600; that should be safe.
ttyUSB2<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
Found a modem on /dev/ttyUSB0.
Modem configuration written to /etc/wvdial.conf.
ttyUSB0<Info>: Speed 9600; init "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"
ttyUSB2<Info>: Speed 9600; init "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"
3:确认设备名,替换配置文件
将下面的配置文件改为你找到的设备名,如上面的/dev/ttyUSB0
替换掉
Modem = /dev/ttyUSB0
即可
KOOK-SLED11164:~ # cat /etc/wvdial.conf
[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = Analog Modem
ISDN = 0
New PPPD = yes
Phone = #777
Modem = /dev/ttyUSB0
Username = vnet.mobi
Password = ctnet@mycdma.cn
Baud = 9600
[Dialer cdma1x]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = Analog Modem
ISDN = 0
New PPPD = yes
Phone = #777
Modem = /dev/ttyUSB0
Username = CARD
Password = CARD
Baud = 460800
4: 拨号后,放入后台
KOOK-SLED11164:~ # wvdial & disown
HP rx6600 itanium 安装SLES-10-SP3-IA64版本操作记录
[
|
2010/06/09 19:18]
|
2010/06/09 19:18]
引用
主机:HP Integrity rx6600
键盘、鼠标、显示器全配。
操作系统: SUSE Linux Enterprise Server 10 SP3 for Itanium
安装介质:DVD光盘 SLES-10-SP3-DVD-ia64-GM-DVD1.iso
操作系统下载:http://download.novell.com/Download?buildid=aSUV5T9tm8Y~
MD5信息:SLES-10-SP3-DVD-ia64-GM-DVD1.iso 69b3dc0880aab630ae72f54ce458f0ad
首先说一下这种需求很少见的,以致于我需要现去官网下载光盘。小机上跑Linux,无论是PPC版本的,还是itanium版本的,这种服务器不跑AIX,不跑HP-UX,跑Linux,为啥?别问我,我只负责安装。说句实在的,去安装之前就从没有在安腾的服务器上安装过Linux,做了点基础性的信息收集工作。查了查,除了引导跑elilo,觉得也没有啥吧。算了,直接正题,到了客户那里,插入光盘,进入启动项“Boot Menu”---“Internal Bootable DVD”,然后光盘启动,哈哈!看到最简单的图形菜单,选择“Installation”,开始出现
引用
Umcompressing Linux ...done
Loading file initrd ...done
于是就时间就停止在这里了,等有进展已经过去5个小时了。一开始我以为就是初始化需要等得久一点呗,那就等呗,结果中午去吃饭,下午回来仍旧如此。中间做过的一些没有用的调整就不说了,中间还做了一个安腾版本的安装服务器部署,用来直接网络安装安腾版本的服务,后来证实速度很快,一会追加在底部。
问题的转机在下午,HP的工程师过来配RAID,我再那里左尝试,右尝试,都没有试验出任何东西。直到这个哥们,用串口帮忙尝试安装一下系统,结果很快就出现了安装界面。我困惑了,为什么串口终端可以安装,我这里就不成呢,于是跟HP的硬件工程师交流,是不是串口拿到图形的优先级要高,当加载镜像,进入安装界面时,那里的显示输出不再输出到VGA卡上,而是直接输出到串口了,这哥们思考了一下说,这个问题好像真的有。那赶紧啊,看看哪里的设置进行一下调整。于是得到解决办法。
结论:在安装过程初始中,VGA和串口都拿到显示输出,而在当前系统的设置下,当操作系统进入加载initrd之后,显示输出只输出到串口,而VGA接显示器的没有输出了。
解决办法:在HP的Boot Menu里面有一项Console Configuration里面有关于Serial和VGA的设定,分别为Primary和Secondary,于是便出现这样的问题。将VGA设定为Primary就可以了。
补充一下关于安腾版本基于Autoyast的部署服务器做法:
主要参考我的这篇文章吧http://www.52zhe.cn/read.php/198.htm,我这里主要讲一下差别在哪里。另外关于安腾的这个服务制作,我参考了http://www-uxsup.csx.cam.ac.uk/pub/doc/suse/sles9/adminguide-sles9/ch04s03.html
区别:
1:DHCP Server
filename "elilo.efi";
2: /tftpboot目录
linux initrd textmenu elilo.conf elilo.efi ----- from sles10 sp3 ia64 DVD \boot\ia64\images
具体提取方法:
mount -o loop,ro /media/cdrom/boot/image /mnt
cd /mnt/efi/boot
cp -p linux initrd textmenu elilo.conf /tftpboot
cp -p bootia64.efi /tftpboot/elilo.efi
umount /mnt
3:自己调整启动需要加载的服务器安装源位置
注意将install=nfs://192.168.0.1/source/sles103ia64追加到append的所在行里面,注意要在引号里面。
cat elilo.conf
prompt
timeout=100
default=linux
chooser=textmenu
message=textmenu
relocatable
# default
image=linux
label=linux
description = "Installation"
initrd=initrd
append="ramdisk_size=131072 install=nfs://192.168.0.1/source/sles103ia64"
# failsafe
image=linux
label=failsafe
description = "Installation - Safe Settings"
initrd=initrd
append="ramdisk_size=131072 ide=nodma nohalt install=nfs://192.168.0.1/source/sles103ia64"
# manual
image=linux
label=manual
description = "Manual Installation"
initrd=initrd
append="ramdisk_size=131072 manual=1 insmod=usbcore insmod=uhci-hcd insmod=ohci-hcd insmod=ehci-hcd insmod=hid install=nfs://192.168.0.1/source/sles103ia64"
# rescue
image=linux
label=rescue
description = "Rescue System"
initrd=initrd
append="ramdisk_size=131072 rescue=1 install=nfs://192.168.0.1/source/sles103ia64"
自己cat textmenu一下吧。
想想遗漏了什么没有?剩下的就简单了,正常系统安装就OK了。没有什么太特殊的。想到再添加吧。
还真就想到了,一个是网络安装时dhcp获取IP时,非常傻,一共6个网卡,轮询来处理,恰好那个网卡是第五个。于是就等了很久,这个需要解决办法。
还想到一点,如果就是没有显卡输出,怎么安装系统?想到可以网络安装,但是至少应该选择PXE启动啊,除非是默认PXE。麻烦,再想想吧。
crontab无法使用bash的build-in函数
[
|
2010/02/04 11:14]
|
2010/02/04 11:14]
操作系统:Debian cat /etc/debian_version squeeze/sid
事情这样地,写了一个脚本,里面有bash的内建命令,有for循环之类的。使用的时候发现无法执行。如果去掉for循环,直接执行命令,就OK,我就奇怪这是为什么?
仔细的查了一下,发现了原因。
ha01:~/bin# grep -v ^# /etc/crontab
MAILTO=root
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
ha01:/bin# ls -al /bin/sh
lrwxrwxrwx 1 root root 4 12月 1 12:45 sh -> dash
原因已经确认,debian默认crontab里面用的是dash而不是shell,那修改也就简单了。
ha01:~# rm /bin/sh
ha01:~# ln -s /bin/bash /bin/sh
事情这样地,写了一个脚本,里面有bash的内建命令,有for循环之类的。使用的时候发现无法执行。如果去掉for循环,直接执行命令,就OK,我就奇怪这是为什么?
仔细的查了一下,发现了原因。
ha01:~/bin# grep -v ^# /etc/crontab
MAILTO=root
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
ha01:/bin# ls -al /bin/sh
lrwxrwxrwx 1 root root 4 12月 1 12:45 sh -> dash
原因已经确认,debian默认crontab里面用的是dash而不是shell,那修改也就简单了。
ha01:~# rm /bin/sh
ha01:~# ln -s /bin/bash /bin/sh




