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.

Compile, install Apache Portable Runtime (APR) on Ubuntu

Compile and install APR
root needed!

Download source packages, apr-1.5.2.tar.gz and apr-util-1.5.4.tar.gz, from Apache site, https://apr.apache.org/download.cgi

Unpack the packages to /root/apache/apr-1.5.2 and /root/apache/apr-util-1.5.4

Installation path: /usr/local/apr

# compile and install apr
# /root/apache/apr-1.5.2
./configure --prefix=/usr/local/apr
make
make install
# compile and install apr-util
#/root/apache/apr-util-1.5.4
./configure --prefix=/usr/local/apr/lib --with-apr=/usr/local/apr
make
make install

For Tomcat
Compile and install tomcat native
Go to tomcat/bin, unpack tomcat-native.tar.gz, then go to tomcat-native-1.1.29-src/jni/native, compile and install tomcat-native

# /home/root/apache-tomcat-7.0.53/bin/tomcat-native-1.1.29-src/jni/native
./configure --with-apr=/usr/local/apr --with-java-home=/usr/lib/jvm/java-VERSION-oracle/
make
make install

Configuration
In the start script of Tomcat, add

CATALINA_OPTS="$CATALINA_OPTS -Djava.library.path=/usr/local/apr/lib"

In conf/server.xml, update protocol of connectors to use the following protocols,

org.apache.coyote.http11.Http11AprProtocol
org.apache.coyote.ajp.AjpAprProtocol

Restart tomcat, if you see the following in the catalina.out and no exception, the APR is running.

...
INFO: Loaded APR based Apache Tomcat Native library 1.1.29 using APR version 1.5.2.
Nov 26, 2015 2:58:54 PM org.apache.catalina.core.AprLifecycleListener init
...

iptables 规则行号,删除及插入规则

# 显示iptables规则行号
iptables -nL --line-numbers
# 删除某行规则
iptables -D INPUT 11
# 在某行插入新的规则,原来的规则会自动下移
iptables -I INPUT 13 -s 1.2.3.4 -p tcp -m state --state NEW --dport 22 -j ACCEPT

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

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

在Ubuntu中更改时区

上次按网上说的用 拷贝文件的方式改就吃过亏了,cron应该是读取/etc/timezone来进行调度的。在Ubunut上正确修改时区的命令应该是

dpkg-reconfigure tzdata

更改后

fp@fp2:~$ cat /etc/localtime
TZif2UTCTZif2UTC
UTC0
 
fp@fp2:~$ cat /etc/timezone 
Etc/UTC
 
fp@fp2:~$ date
Sun Sep 7 11:13:52 UTC 2014

Ubuntu 中升级至 JDK7

sudo apt-get update
sudo apt-get install software-properties-common python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
sudo update-alternatives --config java

Apache NameVirtualHost中IP到域名的Rewrite

有台apache服务器,想把所有通过IP的http访问重定向到域名http://dev.ymeng.net,结果完全没效果,VirtualHost配置如下

<virtualhost *:80>
    DocumentRoot /var/www/html/dev.ymeng.net
    ServerName dev.ymeng.net
    ErrorLog /var/log/apache2/dev.ymeng.net-error_log
 
    <directory "/var/www/html/dev.ymeng.net">
      Order allow,deny
      Deny from all
      Allow from 212.5.5.1
    </directory>
</virtualhost>
 
<virtualhost *:80>
    DocumentRoot /var/www/html/dev.ymeng.net
    ServerName 217.12.15.69
    ErrorLog /var/log/apache2/dev.ymeng.net-error_log
 
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^217\.12\.15\.69
    RewriteRule ^(.*)$ http://dev.ymeng.net [R,L]
 
    <directory "/var/www/html/dev.ymeng.net">
      Order allow,deny
      Deny from all
    </directory>
</virtualhost>

仔细检查后,发现NameVirtualHost被注释掉了
NameVirtualHost *:80

使用 curl 上传文件

 

curl -u httpuser:httppassword -F “postParameterName=value” -F “fileFieldName=@fileNameInOs” http://dev.ymeng.net/upload.php

  • -u 指定http认证用户名及密码
  • -F 指定使用HTTP multipart POST方式发送参数
  • @ 读取文件

 

php处理代码

 

< ?php
$parameterValue = $_POST['postParameterName'];
$uploadedFileName = $_FILES['fileFieldName']['name'];
$uploadedFileSize = $_FILES['fileFieldName']['size'];
 
// move_uploaded_file...
?>