Process state codes in ps

The meaning of values of column STAT in output of ps command on Linux.

PROCESS STATE CODES
       Here are the different values that the s, stat and state output specifiers (header "STAT" or "S") will display to describe the state of a process:
       D    uninterruptible sleep (usually IO)
       R    running or runnable (on run queue)
       S    interruptible sleep (waiting for an event to complete)
       T    stopped, either by a job control signal or because it is being traced.
       W    paging (not valid since the 2.6.xx kernel)
       X    dead (should never be seen)
       Z    defunct ("zombie") process, terminated but not reaped by its parent.
 
       For BSD formats and when the stat keyword is used, additional characters may be displayed:
       < high-priority (not nice to other users)
       N    low-priority (nice to other users)
       L    has pages locked into memory (for real-time and custom IO)
       s    is a session leader
       l    is multi-threaded (using CLONE_THREAD, like NPTL pthreads do
       +    is in the foreground process group.

Linux commands

# delete the 23rd line from ACCOUNT_LOG.sql and save, and create a backup file named ACCOUNT_LOG.sql.bak
# it takes about 20 seconds to update a file with 2Gb
sed -i.bak -e '23d' ACCOUNT_LOG.sql

Send email via openssl command line

root@localhost$ openssl s_client -crlf -quiet -starttls smtp -connect mail.server.com:465
depth=0 OU = GT85507400, OU = See www.rapidssl.com/resources/cps (c)14, OU = Domain Control Validated - RapidSSL(R), CN = *.name.com
verify ...
250 HELP
> EHLO client.com
250-mail.server.com Hello client.com [192.168.1.2]
250-SIZE 52428800
250-8BITMIME
250-PIPELINING
250-AUTH PLAIN LOGIN
250 HELP
> AUTH LOGIN
334 VXNlcm5hbWU6
> [base64 code of username]
334 UGFzc3dvcmQ6
> [base64 code of password]
235 Authentication succeeded
> MAIL FROM:support@server.com
250 OK
> RCPT TO:yang@client.com
250 Accepted
> DATA
354 Enter message, ending with "." on a line by itself
> Subject:mail sending with mail.server.com
> This is a test mail from mail.server.com, sent by openssl.
> .
250 OK id=1YGmlz-0049vF-0V
> quit
221 mail.server.com closing connection

> 开始的行是客户端需要输入的命令。

iptables

周末在家装OpenVPN,结果发现客户端能成功连上服务器,但却没法访问外网。
重新审查服务器端的所有操作步骤,完全正常。还发现一个问题,偶尔会有成功访问外网的时候,但如果重启服务器,又不能访问了。冥思苦想后……

终于发现,原来是服务器的iptables没有启动~

Linux下安装memcached和编译PHP扩展

虽然之前一直做PHP的开发,但一直没有用过memcache,仅是知道一些简单的原理。今天突然来兴趣,想试一下memcache,和PHP下的调用。

1. 安装memcached (服务器版本1.2.6)

服务器OS是RHEL5(Red Hat Linux Enterprise 5),之前已经装好LAMP环境,这是我们的一台测试服务器,LAMP均位于/opt/lamp下。准备将memcached安装在/opt/cache/memcached目录下。

memcached需要libevent(http://monkey.org/~provos/libevent/)的支持,所以需要先安装libevent,安装目录位于/opt/cache/libevent,下载最新版本的libevent(此例中为1.4.8),解压后进入源代码目录,进行配置和安装。

./configure --prefix=/opt/cache/libevent
 
make
 
make install

接着安装memcached,使用的版本是1.2.6,进入解压后的源代码目录,

./configure --prefix=/opt/cache/memcached --with-libevent=/opt/cache/libevent

–with-libevent指令指定libevent的目录
继续阅读“Linux下安装memcached和编译PHP扩展”