Tag Archives: Server

[Linux笔记]Axel多线程多节点下载器

Leave a comment

有时候在Linux下载文件时很纠结,明明手上有多个节点。但是没办法利用多个节点进行加速下载同一个文件。近日找到一个软件”Axel”正合使用。
32位CentOS执行下面命令:

wget -c http://pkgs.repoforge.org/axel/axel-2.4-1.el5.rf.i386.rpm
rpm -ivh axel-2.4-1.el5.rf.i386.rpm

64位CentOS执行下面命令:

wget -c http://pkgs.repoforge.org/axel/axel-2.4-1.el5.rf.x86_64.rpm
rpm -ivh axel-2.4-1.el5.rf.x86_64.rpm

Debian/Ubuntu安装Axel:

apt-get install axel

Continue reading

[Linux笔记]Linux守护进程

2 Comments

之前写过一个针对Linux环境下的Nginx守护进程,现在来个增强版的.同学们看着改来用吧.

ipv4=`ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"`
#把[email protected]改成自己的邮箱
[email protected]
#可以把nginx改为其他要守护的进程名字
nd=`pgrep -f nginx | wc -l`
if [ "$nd" = 0 ]
then
echo -e "Server IP is : $ipv4 " | mail -s "The nginx program is Dead" $EMAIL_TO
/usr/local/nginx/sbin/nginx #当被守护进程不存在后,自动启动的进程。可修改
/usr/local/php/sbin/php-fpm start #当被守护进程不存在后,自动启动的进程。可修改
else
echo "the program is running"
fi

Continue reading

[Linux笔记]-bash: crontab: command not found

Leave a comment

我安装Centos喜欢text linux模式,同时取消所有安装包进行干净安装,安装完成的Centos是最轻量的。在帮朋友安装的时候也是如此,安装完成后他们跟我说:执行crontab -e命令时提示-bash: crontab: command not found无法执行。

其实这是因为安装crond的时候没安装vixie-cron包,导致缺少crontab命令,解决该错误,yum安装上就可以了。执行:

Continue reading

[Linux笔记]CentOS添加与批量添加IP

Leave a comment

一、添加单个IP的方法:

cd /etc/sysconfig/network-scripts  
cp ifcfg-eth0 ifcfg-eth0:0  
vim ifcfg-eth0:0  
DEVICE=eth0:0           #此处添加:0,保持和文件名一致,添加多个IP依次递增  
ONBOOT=yes              #是否开机激活  
BOOTPROTO=static        #静态IP,如果需要DHCP获取请输入dhcp  
IPADDR=192.168.0.2      #此处修改为要添加的IP  
NETMASK=255.255.255.0   #子网掩码根据你的实际情况作修改  

Continue reading

[Linux笔记]Find命令搜索批量删除文件

2 Comments

我们下载某些文件时,常常会夹带一些我们不想要的东西。在Linux环境下怎样通过命令自动搜索他们并删除呢?
可以使用下面这条命令:

#find ./ -name test.html | xargs rm -rf

命令解释:通过find命令搜索当前目录下(./指当前目录)并递归子目录;参数[-name]搜索文件名test.html的同时;构造参数列表并运行命令[xargs]删除且不询问[rm -rf].
同样支持通配符: Continue reading

[Linux笔记]diff命令对比文本

Leave a comment

Windows下有很多工具可以对比两个文本文件,其实Linux下也有比较方便的对比工具。如diff命令:

diff [选项] file1 file2

这个命令告诉用户,file1和file2有哪几行不同内容,方便修改它。如果是file1和file2是文件夹,则对比这两个目录下同名文件的内容。

选项参数: Continue reading