List of Solaris commands for process management



List of Solaris commands for process management


apptrace – for tracing library calls
dtrace – debugger, new in version 10
pargs – get list of arguments and environment variables with which process was started
pfiles – list of file descriptors, associated with process
pgrep – get the PID's of processes by name i.e. Something like ps -efl|grep -v grep|grep process_name
pkill – send signal to process. For example pkill -9 init :-P
pldd – list dynamic libraries, associated with process, similar to ldd for executable
plockstat – see list of locked by process files. Lock can be mutex i.e. exclusive and reader/writer for shared access
pmap – get memory map (segments) of process
preap – try to kick-off zombie process
prstat – fullscreen view of processes sorted by different criteria, similar to Linux top command
prun – continue hold with pstop process
ps - print process information and status. In Solaris exist SYSV and BSD variants, respectively /usr/bin/ps and /usr/ucb/ps
psig – list signals that can be handled by process
pstack – get backtrace stack of process for debugging purposes
pstop – temporary hold process
ptree - print the tree of processes
pwait – wait till process finish
pwdx – list working directory for process, like pwd command
truss – for tracing user/library/system calls and signals



# apptrace man
-> man      -> atexit(int (*)() = 0xd27d6bfc)
<- man      ->
-> man      -> atexit(int (*)() = 0x8054e8c)
<- man      ->
-> man      -> __fpstart(void)
<- man      -> = 0xd251fc94
-> man      ->, 0x1, 0x8047e30) ** NR
-> man      -> * setlocale(int = 0x6, const char * = 0x8055980 "")
<- man      -> = 0xd25002ed
-> man      -> * setlocale(int = 0x5, const char * = 0x0 <NULL>)
<- man      -> = 0xd25002ed
-> man      ->, 0xd25002ed, 0x8047e30) ** NR
-> man      -> strcmp(const char * = 0x805597c "C", const char * = 0x80669e8 "C")
<- man      ->
-> man      -> * textdomain(const char * = 0x8055968 "SUNW_OST_OSCMD")
<- man      -> = 0x80683e0
-> man      ->, 0x8055960, 0x8047e30) ** NR
-> man      -> * getenv(const char * = 0x8054fc0 "MANPATH")
<- man      ->
-> man      ->, 0x2f, 0x8047e30) ** NR
-> man      -> strcmp(const char * = 0x8047e98 "man", const char * = 0x8054fb8 "apropos")
<- man      -> = 0xc
-> man      -> strcmp(const char * = 0x8047e98 "man", const char * = 0x8055958 "whatis")
<- man      -> = 0xfffffff6
-> man      -> strcmp(const char * = 0x8047e98 "man", const char * = 0x8055944 "catman")
<- man      -> = 0xa
-> man      -> getopt(int = 0x1, char *const * = 0x8047de4, const char * = 0x8066420 "FfkrP:M:T:ts:lad")
<- man      -> = 0xffffffff
-> man      -> * gettext(const char * = 0x8055838 "usage:        man [-] [-adFlrt] [-M path] [-T macro-package ] [ -s  section ] name ...
        man [-M path] -k keyword ...
        man [-M path] -f file ...")
<- man      -> = 0x8055838
-> man      -> fprintf(FILE * = 0x8067610, const char * = 0x8054f7c "%s
", void * = 0x8055838, ...)
usage:  man [-] [-adFlrt] [-M path] [-T macro-package ] [ -s section ] name ...
        man [-M path] -k keyword ...
        man [-M path] -f file ...
<- man      -> = 0x88
-> man      ->, 0x8047e30, 0x8047da0) ** NR

in the above example you can clearly see library calls as fprintf(), strcmp(), getenv(), etc.


# pargs 558
558:    /usr/lib/sendmail -Ac -q15m
argv[0]: sendmail: Queue runner@00:15:00 for /var/spool/clientmqueue


Fedora 12升级Chromium遇到的问题及解决方法

自打装好Fedora 12之后就发现chromium不能用rpm安装了,安装时总是缺这少那,很是费劲,于是按照网上的方法,在/etc/yum.repos.d/下创建一个chromium.repo,内容如下:

name=Chromium Test Packages




今天在Fedora People看到有新的chromium安装包出现,于是打算升级chromium。下载了所有的rpm包(忘记了最初是通过yum安装的)。安装时chromium, chromium-libs都能通过rpm -Uvh正常安装,可是升级v8时还是出了问题。想起以前的教训,打算先把v8完全卸载再安装,可是缺无法卸载,无论是通过rpm -e还是yum remove都不行。


这时想到了用yum upodate v8-*,结果却出现了“Package v8-devel-2.0.3-1.20091209svn3443.fc12.i686.rpm is not signed”的错误。在网上找到一个办法,就是编辑 /etc/yum.conf
,把gpgcheck=1 改为 gpgcheck=0。不过这样做有潜在的风险,因此在安装完v8之后就立刻把gpgcheck重新设为1.




SELinux is preventing /usr/lib/chromium-browser/chromium-browser from loading
/usr/lib/chromium-browser/ which requires text relocation.
Detailed Description:
The chromium-browse application attempted to load
/usr/lib/chromium-browser/ which requires text relocation. This is a
potential security problem. Most libraries do not need this permission.
Libraries are sometimes coded incorrectly and request this permission. The
SELinux Memory Protection Tests
( web page explains how to
remove this requirement. You can configure SELinux temporarily to allow
/usr/lib/chromium-browser/ to use relocation as a workaround, until
the library is fixed. Please file a bug report.
Allowing Access:
If you trust /usr/lib/chromium-browser/ to run correctly, you can
change the file context to textrel_shlib_t. "chcon -t textrel_shlib_t
'/usr/lib/chromium-browser/'" You must also change the default file
context files on the system in order to preserve them even on a full relabel.
"semanage fcontext -a -t textrel_shlib_t
Fix Command:
chcon -t textrel_shlib_t '/usr/lib/chromium-browser/'
Additional Information:
Source Context                unconfined_u:unconfined_r:unconfined_execmem_t:s0-
Target Context                system_u:object_r:lib_t:s0
Target Objects                /usr/lib/chromium-browser/ [ file ]
Source                        chromium-browse
Source Path                   /usr/lib/chromium-browser/chromium-browser
Port                          <Unknown>
Host                          bonn.yang
Source RPM Packages           chromium-
Target RPM Packages           chromium-libs-
Policy RPM                    selinux-policy-3.6.32-56.fc12
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Plugin Name                   allow_execmod
Host Name                     bonn.yang
Platform                      Linux bonn.yang #1 SMP
                              Wed Dec 9 11:00:30 EST 2009 i686 i686
Alert Count                   11
First Seen                    Wed 23 Dec 2009 09:38:16 PM CST
Last Seen                     Wed 23 Dec 2009 10:28:36 PM CST
Local ID                      b1f55f28-145d-48dd-9d71-6fb7fe6a57c8
Line Numbers                  
Raw Audit Messages            
node=bonn.yang type=AVC msg=audit(1261578516.240:27332): avc:  denied  { execmod } for  pid=2946 comm="chromium-browse" path="/usr/lib/chromium-browser/" dev=sda2 ino=277322 scontext=unconfined_u:unconfined_r:unconfined_execmem_t:s0-s0:c0.c1023 tcontext=system_u:object_r:lib_t:s0 tclass=file
node=bonn.yang type=SYSCALL msg=audit(1261578516.240:27332): arch=40000003 syscall=125 success=no exit=-13 a0=8ff8000 a1=63000 a2=5 a3=bf899bf0 items=0 ppid=1 pid=2946 auid=500 uid=500 gid=500 euid=500 suid=500 fsuid=500 egid=500 sgid=500 fsgid=500 tty=(none) ses=1 comm="chromium-browse" exe="/usr/lib/chromium-browser/chromium-browser" subj=unconfined_u:unconfined_r:unconfined_execmem_t:s0-s0:c0.c1023 key=(null)



)发现了这样一条命令来取消 SELinux 对 /usr/lib/chromium-browser/下的所有.so文件的permission 的检查。


chcon -t texrel_shlib_t /usr/lib*/chromium-browser/*.so












hcon -t textrel_shlib_t '/usr/lib/chromium-browser/'


semanage fcontext -a -t textrel_shlib_t



实在是太粗心了,当时竟然没有仔细看…… 谨记这一教训!

Fedora 12安装Android SDK


Fedora 12安装Android SDK

1. 下载Android SDK

由于android网站国内不能直接访问, 请通过以下网址下载


Mac OS X (intel):

Linux (i386):

ADT Plugin for Eclipse 0.9.3:

ophone develop :

android developer:

2. 添加Android SDK

运行android后,在选择Available Packages时遇到错误消息:
Failed to fetch URL, reason: HTTPS SSL error. You might want to force download through HTTP in the settings.
  • 创建配置文件: ~/.android/androidtool.cfg,在该文件中添加一行



  • 打开"Settings" 选项并选中misc section "force https:// ... sources to be fetched using http://..." ,重启android. (点击Save后没有反应,重启后发现该选项并没有选中,无效)
  • export GDK_NATIVE_WINDOWS=true before running android sdk manager. 
    It fixes both the save button and the install button for me. (该方法可行)


3. 为Eclipse安装ADT插件

安装ADT的方法Installing and Updating ADT
遇到的问题:During installation, there's an error about requiring org.eclipse.wst.sse.ui. 

The Google Plugin for Eclipse depends on other specific Eclipse components, such as WST. Your installation of Eclipse may not yet include all of them, but they can be easily installed by following these instructions.

Eclipse 3.5 (Galileo)


  1. Select Help > Install New Software...
  2. Click the hyperlink for Available Software Sites.
  3. Ensure there is an update site named Galileo. If this is not present, click Add... and enter for the Location.(在这一步,添加完Galileo之后,最好能安装一下这个site的可用的关键更新)
  4. Now go through the installation steps; Eclipse should download and install the plugin's dependencies.

完成上面的步骤之后,Google App Engine和 Web Toolkit插件就被安装到了Eclipse。此时你仍然需要按照所陈述的步骤再安装ADT并配置SDK。

如果按照上述方法仍然无法安装ADT,最好通过System->Administration->Add/Remove Software彻底删除Eclipse,删除$HOME/.eclipse文件夹,更新操作系统,然后重装Eclipse。如果选择自己下载Eclipse,运行时很可能会遇到"JVM terminated. Exit Code=-1"的问题。因此还是建议通过Add/Remove Software或者yum install eclipse安装。重新安装完eclipse,再按照上述步骤先安装GAE和GWT,然后安装ADT。



 尽管Linux版Chrome浏览器还没有正式发布,Fedora早已官方支持Google的Chromium了。Fedora社区会定期build最新的稳定版Chromium,可以在下载到。当然也可以下载Google 每天build的二进制版Chromium,不过就是这些都不一定稳定:


如果要安装Fedora社区的Chromium,需要下载v8, v8-devel和chromium,目前最新的版本是











1. 共享库





gcc -shared -fPIC -Wmyfun.c -0 
解释: -shared 生成共享库; 
      -fIPC 表示“位置无关代码”(Position Independent Code),可不加; 
      -W 表示输出警告信息,可不加; 

      gcc xxx.c -0 xxx.out -lmy 
    -l 表示设定要连接的库(,输my便可) 


2. 静态库 

先编译成目标文件 gcc -o mylib.o -c lib.c 
然后创建静态库,将mylib.o放到libmylib.a中 ar rcs libmylib.a mylib.o 
最后copy到库目录下/usr/lib  cp libmylib.a /usr/lib/libmylib.a 

如 gcc -o test test.c -lmylib  //mylib是前面创建的库的名称 

3. 动态库

创建就是 gcc -fPIC -share -o lib.c 
一种方法是 gcc -o test test.c ./ (注意这里跟的是动态库的路径 )
第二种方法是使用动态库的函数 你man dlopen看下那几个函数看下就知道了就不多说了


The  -e option is handy for quick Perl operations
from the command line. Want to change all instances of "oldstring" in
Wiffle.bat to "newstrong"? Try


perl -i.old -p -e "s/ oldstring/ newstrong/g" wiffle.bat



This says: "Take each line of  Wiffle.bat (-p); store the original in Wiffle.old (-i); substitute all instances of  oldstring with newstrong (-e); write the result (-p) to the
original file (-i)."


Other PERL command line options are:



 Perl 5 Command-Line Switches


Option Arguments Purpose Notes
-0 octal character code Specify record separator Default is newline (/n)
-a none Automatically spli recordst Used with -n or or -p
-c none Check syntax only Do not execute
-d none Run script using Perl debugger If Perl debugging option was included when Perl was installed
-D flags Specify debugging behavior See table 2
-e command Pass a command to Perl from the command line Useful for quick operations
-F regular expression If -a used Expression to split by default is white space
-i extension Replace original file with results Useful for modifying contents of files
-I directory Specify location of include files  
-l octal character code Drop newlines when used With -n and -p and use designated character as
line- termination character
-n none Process the script using each specified file as an argument Used for performing the same set of actions on a set of files
-p none Same as -n but each line is printed  
-P none Run the script through the C preprocessor before Perl compiles it  
-s none Enable passing of arbitrary switches to Perl Use -s -what -ever to have the Perl variables $what
and $ever defined within your script
-S none Tell Perl to look along the path for the script  
-T none Use taint checking; don't evaluate expressions supplied on the
command line
-u none Make Perl dump core after compiling your script; intended to allow
for generation of Perl executables
Very messy; wait for the Perl compiler
-U none Unsafe mode; overrides Perl's natural caution Don't use this!
-v none Print Perl version number  
-w none Print warnings about script syntax Extremely useful, especially during development  



由于' '不是Tcl所能识别的操作符,因此在Tcl中使用Awk命令时不能用exec awk '/pattern/ {do_something}' file这种命令,即使在''前面加上/也不行。' ’ 可以被Bource Shell和其它shell识别,但是由于exec awk命令是在Tcl中解释的。


如果要在Tcl中执行awk命令,方法有两种:一是用“”代替' ',但是要考虑到需要把某些Tcl的特殊字符用/转义;二是用{}代替' '。比如语句

exec awk '/{print /"blah/"/}' temp.fil 



exec awk "/somePattern/ {print /$0}" someFile



exec awk {/somePattern/ {print $0}}  someFile 


cronjob and crontab


今天要设置一个cron job,查了一些资料,发现了很好的一篇文章,见下文,原文参见:

但是我按照这篇文章的介绍,在Solaris 9下设置crontab的文件时,老是报错

$ crontab chkbjservers.cron
crontab: error on previous line; unexpected character found in line.
crontab: errors detected in input, no crontab file generated.



后来查了Solaris的crontab的手册,发现Solaris的crontab不支持MAILTO,必须要用mailx之类的Unix邮件发送命令。另外,整个cron file只要一句话:minute(s) hour(s) day(s) month(s) weekday(s) command(s). 比如:


30 7 * * 1 /bld/xxxx/mytool/|cat chkbjserver.out|mailx -s "Shared memory checked result in BJ COOL"




What is a cronjob, and how do I use it?

The cron daemon is a long running process that executes commands at specific dates and times. To schedule one-time only tasks with cron, use at or batch. For commands that need to be executed repeatedly (e.g. hourly, daily or weekly), use crontab, which has the following options:

crontab filename Install filename as your crontab file.
crontab -e Edit your crontab file.
crontab -l Show your crontab file.
crontab -r Remove your crontab file. Emails the output to the specified address.

The crontab command creates a crontab file containing commands and how often cron should execute them. Each entry in a crontab file consists of six fields, specified in the following order:

    minute(s) hour(s) day(s) month(s) weekday(s) command(s)

The fields are separated by spaces or tabs. The first five are integer patterns and the sixth is the command to be executed. The following table briefly describes each of the fields.

Field Value Description
minute 0-59 The exact minute that the command sequence executes.
hour 0-23 The hour of the day that the command sequence executes.
day 1-31 The day of the month that the command sequence executes.
month 1-12 The month of the year that the command sequence executes.
weekday 0-6 The day of the week that the command sequence executes. Sunday=0, Monday = 1, Tuesday = 2, and so forth.
command Special The complete command sequence variable that is to be executed.

Each of the patterns from the first five fields may either be an asterisk (*) (meaning all legal values) or a list of elements separated by commas. An element is either a number or two numbers separated by a minus sign (meaning an inclusive range). Note that the specification of days may be made by two fields (day of the month and day of the week). If both are specified as a list of elements, both are followed. For example: 
    0 0 1,15 * 1 /big/dom/xdomain/cgi-bin/scriptname.cgi

The cron daemon would run the program scriptname.cgi in the cgi-bin directory on the first and fifteenth of each month, as well as on every Monday. To specify days by only one field, the other field should be set to *. For example: 
    0 0 * * 1 /big/dom/xdomain/cgi-bin/scriptname.cgi

The program would then only run on Mondays.

If a cron job specified in your crontab entry produces any error messages when it runs, they will be reported to you via email.

You may create crontab files in notepad (being sure to upload them in ASCII) or you may create them within telnet by simply typing:

    mcedit cronfile.txt

For more information, consult the man pages. man pages are the directions and tutorials available to you right at the command line from within telnet. Type any of the following lines to open the relevant tutorials:

    man 5 crontab {enter} 
    man 1 crontab {enter} 
    man cron {enter} 
    man at {enter} 
    man batch {enter} 
    man 1 cron {enter}

Your crontab file must end with a line feed - in other words, make sure to press [Enter] after the last line in the file.

Try It!

Now that you have read an overview of Cron, test your skills by following the steps below. Once completed you should have a cron file of your own! 

Step 1: Create a simple text file using Notepad or any simple text editor that contains the following text: {Enter}
    58 23 * * * /big/dom/xdomain/cgi-bin/

Notes for Step 1

  1. You may create this file using your CNC File Manager by navigating to the /big/dom/xdomain/ directory and clicking 'Create New File' or any other simple text editor such as Notepad.
  2. {Enter} should not actually be typed. [Enter] means hit the {Enter} (return) key to begin the next line and to add a blank line feed at the end of the last line of your Cron File. It is important to always remember to do this.
  3. MAILTO: Replace the email address with a valid email address of your own. This will ensure that when your cronruns, that any output from the script, such as error message, will be emailed to you.
  4. The second line tells your server when to run this script. In this example, the script will be run at 11:58 PM Eastern Time every day of the year.
  5. It is very important that you double check the script path to ensure it is correct and remember the file names are CaSe SeNsiTive.

Step 2: Name the text file. (Example: cronfile.txt)
The cronfile name may be replaced with any name you choose. For instance if you are running a Cron to trigger an email reminder script it could be called reminder.txt. Many choose to simply call it cronfile.txt. 

Step 3: Upload the file in ASCII.
Any standard FTP client or your account's CNC upload feature will work for this. It must be uploaded in ASCII mode and it is recommended that it be placed in your /big/dom/xdomain/ directory. It may be placed anywhere in your account but to prevent browser access (security risks) it is strongly recommended to place it above your /www directory. 

Step 4: Telnet into your account and issue the following command:

    crontab /big/dom/xdomain/cronfile.txt

The above tells the server's crontab where the file is located and that you wish to make it active. Make sure the path to the file is the actual path to where the file was placed. If successful you will be returned to the command bash line, if not an error will be displayed) 


Removing/Stopping the Cron: Deleting the cronfile.txt file from your account will not stop the cron. You may remove this file at any time, since the server's crontab already has the contents, and the cron will still run after you have made it active. 

To turn the cron off you must Telnet into your account and issue the following command:

The crontab -r will deactivate the cronjob and remove the file contents from the server. 

Security Note: If the script the cron is setup to run is in the /cgi-bin/ or /www/ directory it may be run at anytime by anyone with browser access. If the crontab is all that should run the script and you do not want the public to be able to run the script, then you will need to place the script in a directory above the /cgi-bin/ and /www/ directories such as:/big/dom/xdom/user/cronscripts/scriptname






./configure --withtclinclude=/usr/local/src/tcl8.6b1/generic




exp_main_exp.c:32: error: ‘Tcl_Interp’ has no member named ‘result’
exp_main_exp.c:33: warning: incompatible implicit declaration of built-in function ‘exit’
make: *** [exp_main_exp.o] Error 1




我没有再继续尝试编译安装expect。我想起来可以尝试通过yum安装,于是输入yum install expect,竟然成功了!不过在安装expect的同时,还自动安装了tcl8.5.3,估计这是因为安装的expect是基于tcl8.5的源代码变异的。






1.     # ps -eo pid,pcpu,args | sort +1n 

该命令输出当前系统进程的pid, cpu占用率及命令描述,并以pcpu来排序(尝试过,没有成功,据说在RedHat上可行的。)

2. top -p <pid>


3. prstat -p <pid>

prstat 检查系统中进程占用CPU,内存等情况。可以代替top,不过好像solaris5.8之后才有,5.7上就没有。

4. 查看IO情况 iostat

iostat -x -I 1 若系统明显变慢,也可用此命令检查磁盘I/O情况

5. 查看CPU 可以用 psrinfo -v


/usr/platform/sun4u/sbin/prtdiag -v

 6. sar

sar -u 3 20 若系统明显变慢,用此命令检查cpu占用率
sar –r 3 20 用此命令检查内存使用情况