日期:2014-05-16  浏览次数:20573 次

linux 相关命令及注意事项

1. netstat -ntlp 查看系统中运行哪些网络服务,不需要用的都可以关掉

?

?

========================================

结束进程

kill killall pkill

========================================

# ps aux | grep ruby

# kill -9 [PID]


注:并非所有进程都可以通过此方法关闭,好下

例如:


请使用命令“killall httpsqs”、“pkill httpsqs”和“kill `cat /tmp/httpsqs.pid`”来停止httpsqs。



  注意:请不要使用命令“pkill -9 httpsqs”和“kill -9? httpsqs的进程ID”来结束httpsqs,否则,内存中尚未保存到磁盘的数据将会丢失。

========================================

用nohup命令让Linux下程序永远在后台执行

========================================



Unix/Linux下一般想让某个程序在后台运行,很多都是使用 & 在程序结尾来让程序自动运行。比如我们要运行mysql在后台:

???????? /usr/local/mysql/bin/mysqld_safe --user=mysql &

 但是我们很多程序并不象mysqld一样可以做成守护进程,可能我们的程序只是普通程序而已,一般这种程序即使使用 &
结尾,如果终端关闭,那么程序也会被关闭。为了能够后台运行,我们需要使用nohup这个命令,比如我们有个start.sh需要在后台运行,并且希望在
后台能够一直运行,那么就使用nohup:

??????????? nohup /root/start.sh &


实例:

 在Linux下,推送到后台执行即可:
nohup /usr/local/webserver/php/bin/php /opt/httpsqs_client_daemon.php 2>&1 > /dev/null &


========================================

linux 启动时运行程序命令 与之对应的还有定时任务crontab

编辑:vi /etc/rc.local

========================================

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
ulimit -SHn 51200
/usr/local/php/sbin/php-fpm start
/usr/local/nginx/sbin/nginx
/usr/local/bin/memcached -d -m 10 -u root -l 122.225.96.117 -p 11211 -c 256 -P /tmp/memcached.pid
/usr/local/mailgraph_ext/mailgraph-init start
/var/www/extsuite/extman/daemon/cmdserver -v -d
/usr/local/rsync --daemon

?

?

==================================

有时候我们配置了程序,发现程序未执行,但单独测试又完全正常

==================================

?

首先要检查文件是否具有可执行权限

?

chmod +X /sinykkdata/config/svn_export.sh

?

?