系统调用跟我学

最近浏览到一篇不错的文章,略带有科普性质,原文链接:
系统调用跟我学一
系统调用跟我学二
系统调用跟我学三
系统调用跟我学四

coredump

最近在定位一个非必现的问题时存在一个认识错误,在linux中开启coredump的脚本如下:

#!/bin/bash

### Filename: coredumpshell.sh
### Description: enable coredump and format the name of core file on centos system

# enable coredump whith unlimited file-size for all users
echo -e "\n# enable coredump whith unlimited file-size for all users\n* soft core unlimited" >> /etc/security/limits.conf

# set the path of core file with permission 777 
if [ ! -d "/tmp/corefile" ]; then
    mkdir -p /tmp/corefile
fi

chmod 777 /tmp/corefile

# format the name of core file.   
# %% – 符号%
# %p – 进程号
# %u – 进程用户id
# %g – 进程用户组id
# %s – 生成core文件时收到的信号
# %t – 生成core文件的时间戳(seconds since 0:00h, 1 Jan 1970)
# %h – 主机名
# %e – 程序文件名
echo -e "/tmp/corefile/core-%e-%s-%u-%g-%p-%t" > /proc/sys/kernel/core_pattern

# suffix of the core file name
echo -e "1" > /proc/sys/kernel/core_uses_pid

安装man手册

公司内网安装的linux系统,无法使用man命令,可以通过在官网下载进行安装。
源码从这里下载
http://www.kernel.org/pub/linux/docs/man-pages/
下载后解压缩,从终端进入解压后的文件夹,输入命令:
sudo make install
这个命令是把man安装到/user/man目录下面的,这样就已经成功的安装了man
但是如果你不想安装, 我们可以直接在解压后的目录使用
假设解压后文件夹路径是:/home/man,如果不想安装,可以用:
man –M /home/man + 所查询的命令

ps查看进程存活时间

ps命令妙用:查看Linux下某个进程存活时间
查看对应进程名存活时间:
ps -p $(pgrep xxxx) -o pid,cmd,start,etime
查看对应进程id存活时间
ps -p "28590" -o etime,command