正在加载...
分页: 84/186 第一页 上页 79 80 81 82 83 84 85 86 87 88 下页 最后页 [ 显示模式: 摘要 | 列表 ]

修改nginx日志的时间格式

[ 2009/06/05 09:15 | by selboo ]
我需要修改访问日志的时间格式:
原格式为:03/Jun/2009:07:06:53 +0800
需要修改为:2009-06-03 07:06:53

第一个要修改的文件:
nginx-0.7.59/src/core/ngx_times.c

1、(计算字符串的长度?)
static u_char            cached_http_log_time[NGX_TIME_SLOTS]
                                    [sizeof("28/Sep/1970:12:00:00 +0600")];
修改为
static u_char            cached_http_log_time[NGX_TIME_SLOTS]
                                    [sizeof("1970-09-28 12:00:00")];

2、(计算字符串的长度?)
ngx_cached_http_log_time.len = sizeof("28/Sep/1970:12:00:00 +0600") - 1;
修改为
ngx_cached_http_log_time.len = sizeof("1970-09-28 12:00:00") - 1;

3、(关键的地方,修改格式)
    p2 = &cached_http_log_time[slot][0];

    (void) ngx_sprintf(p2, "%02d/%s/%d:%02d:%02d:%02d %c%02d%02d",
                       tm.ngx_tm_mday, months[tm.ngx_tm_mon - 1],
                       tm.ngx_tm_year, tm.ngx_tm_hour,
                       tm.ngx_tm_min, tm.ngx_tm_sec,
修改为
p2 = &cached_http_log_time[slot][0];

    (void) ngx_sprintf(p2, "%4d-%02d-%02d %02d:%02d:%02d",
                       tm.ngx_tm_year, tm.ngx_tm_mon,
                       tm.ngx_tm_mday, tm.ngx_tm_hour,
                       tm.ngx_tm_min, tm.ngx_tm_sec,
注:这里其实将p2格式改成和p1格式基本上相同了,完全可以直接将log_time的格式改成p1,但是为了做个试验,还是手动修改了p2格式。

第二个要修改的文件:
nginx-0.7.59/src/http/modules/ngx_http_log_module.c

    { ngx_string("time_local"), sizeof("28/Sep/1970:12:00:00 +0600") - 1,
修改为
    { ngx_string("time_local"), sizeof("1970-09-28 12:00:00") - 1,

OK,编译即可。
Tags:

防止用户查看其他用户进程

[ 2009/06/05 09:12 | by selboo ]
echo 'security.bsd.see_other_uids=0' >> /etc/sysctl.conf
echo 'security.bsd.see_other_gids=0' >> /etc/sysctl.conf

sysctl security.bsd.see_other_uids=0
sysctl security.bsd.see_other_gids=0

sysctl -a | grep security
Tags: ,

删除表后,自动更新ID

[ 2009/06/03 17:09 | by selboo ]
删除自动ID(auto_increment)表下的内容,会出现ID空档.
例如删除ID=6 ID=7
1 2 3 4 5  8....
这样ID就从8开始记录.
这样需要1个方法让他从6来继续
执行sql语句.
ALTER TABLE `表` AUTO_INCREMENT = 6
Tags:

ping测试批处理

[ 2009/06/02 10:26 | by selboo ]
更新 ping测试批处理(第二版)  http://selboo.com.cn/Ping_Text_Bat_v2/

data.txt
要测试的ip列表

1.bat
生成ping结果

2.bat
提取 ping的 丢包率 最大 最下 平均

loss.txt
生成结果

1.bat
This is The DOS Code
for /f "delims=" %%a in (data.txt) do  (
start /b ping %%a -n 10 -l 32 > %%a.ping
start /b tracert -d %%a > %%a.tracert
)
Parsed in 0.002 seconds at 76.39 KB/s
可以修改 ping 次数 包的大小

2.bat
[codes=dos]for /f
Tags: ,

Office Password Remover

[ 2009/05/31 18:20 | by selboo ]
清空 Word,Excel的文档打开密码

需要连接网络

点击在新窗口中浏览此图片

下载文件 (已下载 193 次)
Tags:
分页: 84/186 第一页 上页 79 80 81 82 83 84 85 86 87 88 下页 最后页 [ 显示模式: 摘要 | 列表 ]