#include #include int main() { struct tm tm; char buf[255]; strptime("2001-11-12 18:31:01", "%Y-%m-%d %H:%M:%S", &tm); strftime(buf, sizeof(buf), "%.....
分类:
其他好文 时间:
2014-08-06 14:44:11
阅读次数:
372
#include #include #includeusing namespace std;int main( void ) { time_t t = time(0); char tmp[64]; strftime( tmp, sizeof(tmp), "%Y/%m/%d %X %A 本年第%j.....
分类:
编程语言 时间:
2014-08-06 14:13:51
阅读次数:
222
#test.sh
#!/bin/bash
dir=/home/test
whilereadline
do
host=`echo$line|awk‘{print$1}‘`
passwd=`echo$line|awk‘{print$2}‘`
$dir/expect_ssh.sh$host$passwd&
done<$dir/host.txt
#expect_ssh.sh
#!/usr/bin/envexpect
setHOST[lindex$argv0]
setPASSWD[lindex$argv..
分类:
系统相关 时间:
2014-08-05 11:33:10
阅读次数:
243
AWK Command: 一 : print print item1,item2,.......... 要点: 1.各项目之间使用逗号隔开,而输入时则以空白字符分隔 2.输出的item可以为字符串或树枝,当前记录的字段(如...
分类:
系统相关 时间:
2014-08-03 22:59:26
阅读次数:
318
awk 学习笔记
最近添加了几个功能的日志,但是呢,这个日志就是输出,一般自己也发现不了问题,于是想写一些简单的监控脚本来看看日志的大致情况,
比如有没有error,每天有多少error报出来。 想到了以前运维的同时分享awk,于是想简单的学习下。
入门
最简单的输入某些列 使用$4 这种来表示 __$0__是输出整列
[root]/root/test$ps -ef|grep...
分类:
系统相关 时间:
2014-08-03 15:24:35
阅读次数:
368
分别用sed awk perl grep 实现:1 sed '/^$/d' input.txt > output.txt #output file: output.txt2 sed -i '/^$/d' input.txt #output file: input.txt3 awk '...
分类:
系统相关 时间:
2014-08-02 12:17:53
阅读次数:
256
监控服务器是否宕机的脚本:$sudoviping.sh按a或i进入编辑模式#!/bin/bashDate=`date+%m%d%y`touch/log/Ping/$Date.logServer="ming1ming2ming3ming4ming5"forServerin$ServerdoPing=`/bin/ping-c4$Server|grep%|awk-F[:""]+‘{print$6}‘|tr-d‘%‘`Ping2=`/bin/ping-c4$Server|gr..
分类:
其他好文 时间:
2014-08-01 20:20:13
阅读次数:
237
文本行中各列打乱:awk 'BEGIN{srand()}{for(i=1;i<=NF;i++) b[rand()NF]=$i}END{for(x in b)printf "%s ",b[x]}'` data文本行中各行打乱:awk 'BEGIN{srand()}{b[rand()NR]=$0}END...
分类:
其他好文 时间:
2014-08-01 18:29:22
阅读次数:
220
#/bin/bash
#
beforTime=02:00
afterTime=08:00
beforTime=$(echo$beforTime|awk-F:{‘print$1‘})
afterTime=$(echo$afterTime|awk-F:{‘print$1‘})
Flag=0
whiletrue
do
sleep2s
echo"date:$(date+"%Y-%m-%d%H:%M:%S")"
if[$(date+%H)-eq$beforTime];then
CurDate=$(date+%d)
..
Python获取当前系统时间
import time
#返回当前时间
def GetNowTime():
return time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(time.time()))
扩展
python中时间日期格式化符号:
%y 两位数的年份表示(00-99)
%Y 四位数的年份表示(000-9999)
%m 月份(01-12)
%d 月内中的一天(0-31)
%H 24小时制小时数(0-23)
%I 12小时制小时数(01-12) ...
分类:
编程语言 时间:
2014-08-01 13:41:41
阅读次数:
237