魏长东

weichangdong

正在查看: linux 分类下的文章(第 3 页 / 共 76 篇)

linux 下查看机器是cpu是几核的

其实也搞不清到底几核,几个cpu之类的。。。。

几个cpu

more /proc/cpuinfo |grep "physical id"|uniq|wc -l

每个cpu是几核(假设cpu配置相同)

more /proc/cpuinfo |grep "physical id"|grep "0"|wc -l

cat /proc/cpuinfo | grep processor

1. 查看物理CPU的个数
#cat /proc/cpuinfo |grep "physical id"|sort |uniq|wc -l
 
2. 查看逻辑CPU的个数
#cat /proc/cpuinfo |grep "processor"|wc -l
 
3. 查看CPU是几核
#cat /proc/cpuinfo |grep "cores"|uniq
 
4. 查看CPU的主频
#cat /proc/cpuinfo |grep MHz|uniq

»»阅读全文

linux grep高级用法

1. 使用用正则表达式

语法:
grep "REGEX" filename


如果你能有效地利用正则表达式,这是个很有用的特点。在下面的例子中,搜索全部以“lines”开始以“empty”结束的字串,如搜索“lines[之间任意字]empty” ,并且忽略大小写。

 

$ grep -i "lines.*empty" demo_file
Two lines above this line is empty.

 

正则表达式遵循的几个重复的操作

  • ? 最多匹配一次
  • * 匹配零次或者任意多次
  • + 匹配一次以上
  • {n} 匹配n次
  • {n,} 最少匹配n次
  • {,m} 最多匹配m次
  • {n,m} 匹配n到m次

»»阅读全文

vim&perl对匹配数字做运算

遇到这样个事情,php读取excel的时候,40多列,然后读取后到一个数组,然后key就是0到40多,然后去除每个列的数值。如下代码,但是突然要在最前面或者中间增加一列,然后数组的数字就的变。

»»阅读全文

linux find 的mtime用法

先上命令

find /data/export  -mtime +20 -a  -size +100M -exec rm -f {} \;
find /data/export  -mtime +40 -exec rm -f {} \;

常用的就是mtime的三种格式:-n n +n

»»阅读全文

perl解析json

[root@swordman perl]# cat  json_t
{"root_path":"pictures\/bbm","count":"15704340","country":"ID","data_type":"1"}
{"root_path":"dcim\/facebook","count":"10421769","country":"ID","data_type":"1"}
{"root_path":"dcim\/100andro","count":"8437408","country":"ID","data_type":"1"}
{"root_path":"android\/data\/com.qihoo.security","count":"8370765","country":"ID","data_type":"1"}
{"root_path":"backucup","count":"7734925","country":"ID","data_type":"1"}
{"root_path":"pictures\/b612","count":"7432353","country":"ID","data_type":"1"}
{"root_path":"pictures\/instagram","count":"6518579","country":"ID","data_type":"1"}
{"root_path":"backucup","count":"6046648","country":"IN","data_type":"1"}
{"root_path":"dcim\/facebook","count":"5875220","country":"IN","data_type":"1"}
{"root_path":"android\/data\/com.qihoo.security","count":"5705046","country":"IN","data_type":"1"}
{"root_path":"android\/data\/com.qihoo.security","count":"4948008","country":"US","data_type":"1"}
{"root_path":"dcim\/100andro","count":"4767237","country":"IN","data_type":"1"}

»»阅读全文

hive中的一些不常见函数的用法

常见的函数就不废话了,和标准sql类似,下面我们要聊到的基本是HQL里面专有的函数,

hive里面的函数大致分为如下几种:Built-in、Misc.、UDF、UDTF、UDAF

我们就挑几个标准SQL里没有,但是在HIVE SQL在做统计分析常用到的来说吧。

1、array_contains (Collection Functions)

这是内置的对集合进行操作的函数,用法举例:

create EXTERNAL table IF NOT EXISTS userInfo (id int,sex string, age int, name string, email string,sd string, ed string)  ROW FORMAT DELIMITED FIELDS 
TERMINATED BY '\t' location '/hive/dw';
 
select * from userinfo where sex='male' and (id!=1 and id !=2 and id!=3 and id!=4 and id!=5) and age < 30;
select * from (select * from userinfo where sex='male' and !array_contains(split('1,2,3,4,5',','),cast(id as string))) tb1 where tb1.age < 30;

»»阅读全文

SIG 信号数值

#define SIGHUP 1
#define SIGINT 2
#define SIGQUIT 3
#define SIGILL 4
#define SIGTRAP 5
#define SIGABRT 6
#define SIGIOT 6
#define SIGBUS 7
#define SIGFPE 8
#define SIGKILL 9
#define SIGUSR1 10
#define SIGSEGV 11
#define SIGUSR2 12
#define SIGPIPE 13
#define SIGALRM 14
#define SIGTERM 15
#define SIGSTKFLT 16
#define SIGCHLD 17
#define SIGCONT 18
#define SIGSTOP 19
#define SIGTSTP 20
#define SIGTTIN 21
#define SIGTTOU 22
#define SIGURG 23
#define SIGXCPU 24
#define SIGXFSZ 25
#define SIGVTALRM 26
#define SIGPROF 27
#define SIGWINCH 28
#define SIGIO 29
#define SIGPOLL SIGIO

#define SIGPWR 30
#define SIGSYS 31
#define SIGUNUSED 31



#define SIGRTMIN 32
#define SIGRTMAX _NSIG

nginx的default配置文件

server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        root           /usr/share/nginx/html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

fluentd 关于wp日志同步

<source>
  type tail
  format none
  path /wcd/safebrowsing.log
  pos_file /wcd/safebrowsing.log.pos
  tag s3.logs.wp_log
</source>

<match s3.logs.wp_log>
  type s3

  aws_key_id  ****
  aws_sec_key ***

  s3_bucket wcd
  s3_region ap-southeast-1
  s3_object_key_format %{path}/dt=%{time_slice}_eu1_%{index}.%{file_extension}
  path wp_log
  buffer_path /wcd/buffer/s3_wp_log
  #flush_interval 1m

  time_slice_format %Y%m%d/%H
  time_slice_wait 10m

  format single_value

  buffer_chunk_limit 2g
  store_as log
</match>