解决nohup命令生成的多余的大日志文件
[
2015/10/10 18:26 | by Totti ]

解决nohup命令生成的多余的大日志文件
经常使用命令
nohup /usr/bin/php /srv/www/update.php &
可以让它在后台安静的进行,但是有一个烦恼就是,它会生成一个日志文件nohup.out
而且这个文件,不断的增加。太占空间了。
网上找了一下,自己以前也记得好可以输出到一个什么设备里面,就可以了。
这次确实了,原来是输出到/dev/null,它就不会管了。
好了,把上面的命令修改一下了。
nohup /usr/bin/php /srv/www/update.php /dev/null &
加入定时任务,就OK了。
还有一点需要注意,就是上面的命令之间,有空格的。否则会报错的。
经常使用命令
nohup /usr/bin/php /srv/www/update.php &
可以让它在后台安静的进行,但是有一个烦恼就是,它会生成一个日志文件nohup.out
而且这个文件,不断的增加。太占空间了。
网上找了一下,自己以前也记得好可以输出到一个什么设备里面,就可以了。
这次确实了,原来是输出到/dev/null,它就不会管了。
好了,把上面的命令修改一下了。
nohup /usr/bin/php /srv/www/update.php /dev/null &
加入定时任务,就OK了。
还有一点需要注意,就是上面的命令之间,有空格的。否则会报错的。
1.nohup 命令
nohup
nohup 命令
用途:LINUX命令用法,不挂断地运行命令。
语法:nohup Command [ Arg ... ] [ & ]
描述:nohup 命令运行由 Command 参数和任何相关的 Arg 参数指定的命令,忽略所有挂断(SIGHUP)信号。在注销后使用 nohup 命令运行后台中的程序。要运行后台中的 nohup 命令,添加 & ( 表示“and”的符号)到命令的尾部。
如果不将 nohup 命令的输出重定向,输出将附加到当前目录的 nohup.out 文件中。如果当前目录的 nohup.out 文件不可写,输出重定向到 $HOME/nohup.out 文件中。如果没有文件能创建或打开以用于追加,那么 Command 参数指定的命令不可调用。如果标准错误是一个终端,那么把指定的命令写给标准错误的所有输出作为标准输出重定向到相同的文件描述符。
退出状态:该命令返回下列出口值:
126 可以查找但不能调用 Command 参数指定的命令。
127 nohup 命令发生错误或不能查找由 Command 参数指定的命令。
否则,nohup 命令的退出状态是 Command 参数指定命令的退出状态。
nohup命令及其输出文件
nohup命令:如果你正在运行一个进程,而且你觉得在退出帐户时该进程还不会结束,那么可以使用nohup命令。该命令可以在你退出帐户/关闭终端之后继续运行相应的进程。nohup就是不挂起的意思( n ohang up)。
该命令的一般形式为:nohup command &
使用nohup命令提交作业
如果使用nohup命令提交作业,那么在缺省情况下该作业的所有输出都被重定向到一个名为nohup.out的文件中,除非另外指定了输出文件:
nohup command > myout.file 2>&1 &
在上面的例子中,输出被重定向到myout.file文件中。
使用 jobs 查看任务。
使用 fg %n 关闭。
另外有两个常用的ftp工具ncftpget和ncftpput,可以实现后台的ftp上传和下载,这样我就可以利用这些命令在后台上传和下载文件了。
2.程序在后台运行 & 开机启动
nohup python yourscript.py &可以让你的程序在后台运行,控制台输出导向nohup.out文件
nohup python server.py
nohup
nohup 命令
用途:LINUX命令用法,不挂断地运行命令。
语法:nohup Command [ Arg ... ] [ & ]
描述:nohup 命令运行由 Command 参数和任何相关的 Arg 参数指定的命令,忽略所有挂断(SIGHUP)信号。在注销后使用 nohup 命令运行后台中的程序。要运行后台中的 nohup 命令,添加 & ( 表示“and”的符号)到命令的尾部。
如果不将 nohup 命令的输出重定向,输出将附加到当前目录的 nohup.out 文件中。如果当前目录的 nohup.out 文件不可写,输出重定向到 $HOME/nohup.out 文件中。如果没有文件能创建或打开以用于追加,那么 Command 参数指定的命令不可调用。如果标准错误是一个终端,那么把指定的命令写给标准错误的所有输出作为标准输出重定向到相同的文件描述符。
退出状态:该命令返回下列出口值:
126 可以查找但不能调用 Command 参数指定的命令。
127 nohup 命令发生错误或不能查找由 Command 参数指定的命令。
否则,nohup 命令的退出状态是 Command 参数指定命令的退出状态。
nohup命令及其输出文件
nohup命令:如果你正在运行一个进程,而且你觉得在退出帐户时该进程还不会结束,那么可以使用nohup命令。该命令可以在你退出帐户/关闭终端之后继续运行相应的进程。nohup就是不挂起的意思( n ohang up)。
该命令的一般形式为:nohup command &
使用nohup命令提交作业
如果使用nohup命令提交作业,那么在缺省情况下该作业的所有输出都被重定向到一个名为nohup.out的文件中,除非另外指定了输出文件:
nohup command > myout.file 2>&1 &
在上面的例子中,输出被重定向到myout.file文件中。
使用 jobs 查看任务。
使用 fg %n 关闭。
另外有两个常用的ftp工具ncftpget和ncftpput,可以实现后台的ftp上传和下载,这样我就可以利用这些命令在后台上传和下载文件了。
2.程序在后台运行 & 开机启动
nohup python yourscript.py &可以让你的程序在后台运行,控制台输出导向nohup.out文件
nohup python server.py
directadmin 升级 apache
[
2014/06/14 00:27 | by Totti ]

You can check the current version of apache by running
/usr/sbin/httpd -v
CustomBuild - current
If you're using custombuild (as most new boxes are), run the following
cd /usr/local/directadmin/custombuild
./build update
./build apache
./build php n
./build rewrite_confs
from:http://help.directadmin.com/item.php?id=1
http://www.wdlinux.cn/old/mod_evasive
http://ljty11.blog.163.com/blog/static/10919414120111126105539342/
http://lxy.me/the-centos-next-script-php-ddos-and-prevention.html
http://www.tianji.me/index.php/centos/114.html
http://forum.bnxb.com/read.php?tid=183
/usr/sbin/httpd -v
CustomBuild - current
If you're using custombuild (as most new boxes are), run the following
cd /usr/local/directadmin/custombuild
./build update
./build apache
./build php n
./build rewrite_confs
from:http://help.directadmin.com/item.php?id=1
http://www.wdlinux.cn/old/mod_evasive
http://ljty11.blog.163.com/blog/static/10919414120111126105539342/
http://lxy.me/the-centos-next-script-php-ddos-and-prevention.html
http://www.tianji.me/index.php/centos/114.html
http://forum.bnxb.com/read.php?tid=183
禁用Apache空主机头
[
2013/05/31 11:12 | by Totti ]

编辑配置文件,在你的站点配置之前再增加一个站点
NameVirtualHost *
ServerAdmin yourmail#mail.com
DocumentRoot /error
ServerName abc.com
NameVirtualHost *
ServerAdmin yourmail#mail.com
DocumentRoot /error
ServerName abc.com
S-ON 手动刷boot.img
fastboot flash boot boot.img
fastboot flash boot boot.img
解决 win7右键管理无法打开的问题
[
2012/12/13 22:52 | by Totti ]

解决办法 把下面的注册表信息 存成这册表文件 然后导入即可
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\Manage]
@=hex(2):40,00,25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,00,6f,00,74,\
00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6d,00,\
79,00,63,00,6f,00,6d,00,70,00,75,00,74,00,2e,00,64,00,6c,00,6c,00,2c,00,2d,\
00,34,00,30,00,30,00,00,00
"MUIVerb"=hex(2):40,00,25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,00,\
6f,00,74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,\
00,6d,00,79,00,63,00,6f,00,6d,00,70,00,75,00,74,00,2e,00,64,00,6c,00,6c,00,\
2c,00,2d,00,34,00,30,00,30,00,00,00
"SuppressionPolicy"=dword:4000003c
"HasLUAShield"=""
[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\Manage\command]
@=hex(2):25,00,77,00,69,00,6e,00,64,00,69,00,72,00,25,00,5c,00,73,00,79,00,73,\
00,74,00,65,00,6d,00,33,00,32,00,5c,00,6d,00,6d,00,63,00,2e,00,65,00,78,00,\
65,00,20,00,2f,00,73,00,20,00,25,00,77,00,69,00,6e,00,64,00,69,00,72,00,25,\
00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,63,00,6f,00,\
6d,00,70,00,6d,00,67,00,6d,00,74,00,2e,00,6d,00,73,00,63,00,00,00
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\Manage]
@=hex(2):40,00,25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,00,6f,00,74,\
00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6d,00,\
79,00,63,00,6f,00,6d,00,70,00,75,00,74,00,2e,00,64,00,6c,00,6c,00,2c,00,2d,\
00,34,00,30,00,30,00,00,00
"MUIVerb"=hex(2):40,00,25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,00,\
6f,00,74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,\
00,6d,00,79,00,63,00,6f,00,6d,00,70,00,75,00,74,00,2e,00,64,00,6c,00,6c,00,\
2c,00,2d,00,34,00,30,00,30,00,00,00
"SuppressionPolicy"=dword:4000003c
"HasLUAShield"=""
[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\Manage\command]
@=hex(2):25,00,77,00,69,00,6e,00,64,00,69,00,72,00,25,00,5c,00,73,00,79,00,73,\
00,74,00,65,00,6d,00,33,00,32,00,5c,00,6d,00,6d,00,63,00,2e,00,65,00,78,00,\
65,00,20,00,2f,00,73,00,20,00,25,00,77,00,69,00,6e,00,64,00,69,00,72,00,25,\
00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,63,00,6f,00,\
6d,00,70,00,6d,00,67,00,6d,00,74,00,2e,00,6d,00,73,00,63,00,00,00
buyvm Debian/Ubuntu OpenVZ一键安装PPTP (vpn)教程
[
2012/12/01 18:30 | by Totti ]

wget http://www.putdispenserhere.com/wp-content/uploads/pptpinstall.sh
chmod +x pptpinstall.sh
./pptpinstall.sh
#!/bin/bash
# Interactive PoPToP install script on a OpenVZ VPS
# Tested on Debian 5, 6, and Ubuntu 11.04
# 2011 v1.1
# Author: Commander Waffles
# http://www.putdispenserhere.com/pptp-debian-ubuntu-openvz-setup-script/
echo "######################################################"
echo "Interactive PoPToP Install Script for OpenVZ VPS"
echo "by Commander Waffles http://www.putdispenserhere.com"
echo "Should work on various deb-based Linux distos."
echo "Tested on Debian 5, 6, and Ubuntu 11.04"
echo
echo "Make sure to message your provider and have them enable"
echo "IPtables and ppp modules prior to setting up PoPToP."
echo
echo "You need to set up the server before creating more users."
echo "A separate user is required per connection or machine."
echo "######################################################"
echo
echo
echo "######################################################"
echo "Select on option:"
echo "1) Set up new PoPToP server AND create one user"
echo "2) Create additional users"
echo "######################################################"
read x
if test $x -eq 1; then
echo "Enter username that you want to create (eg. client1 or john):"
read u
echo "Specify password that you want the server to use:"
read p
# get the VPS IP
ip=`ifconfig venet0:0 | grep 'inet addr' | awk {'print $2'} | sed s/.*://`
echo
echo "######################################################"
echo "Downloading and Installing PoPToP"
echo "######################################################"
apt-get update
apt-get install pptpd
echo
echo "######################################################"
echo "Creating Server Config"
echo "######################################################"
cat > /etc/ppp/pptpd-options <<END
name pptpd
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe-128
ms-dns 8.8.8.8
ms-dns 8.8.4.4
proxyarp
nodefaultroute
lock
nobsdcomp
END
# setting up pptpd.conf
echo "option /etc/ppp/pptpd-options" > /etc/pptpd.conf
echo "logwtmp" >> /etc/pptpd.conf
echo "localip $ip" >> /etc/pptpd.conf
echo "remoteip 10.1.0.1-100" >> /etc/pptpd.conf
# adding new user
echo "$u * $p *" >> /etc/ppp/chap-secrets
echo
echo "######################################################"
echo "Forwarding IPv4 and Enabling it on boot"
echo "######################################################"
cat >> /etc/sysctl.conf <<END
net.ipv4.ip_forward=1
END
sysctl -p
echo
echo "######################################################"
echo "Updating IPtables Routing and Enabling it on boot"
echo "######################################################"
iptables -t nat -A POSTROUTING -j SNAT --to $ip
# saves iptables routing rules and enables them on-boot
iptables-save > /etc/iptables.conf
cat > /etc/network/if-pre-up.d/iptables <<END
#!/bin/sh
iptables-restore < /etc/iptables.conf
END
chmod +x /etc/network/if-pre-up.d/iptables
cat >> /etc/ppp/ip-up <<END
ifconfig ppp0 mtu 1400
END
echo
echo "######################################################"
echo "Restarting PoPToP"
echo "######################################################"
/etc/init.d/pptpd restart
echo
echo "######################################################"
echo "Server setup complete!"
echo "Connect to your VPS at $ip with these credentials:"
echo "Username:$u ##### Password: $p"
echo "######################################################"
# runs this if option 2 is selected
elif test $x -eq 2; then
echo "Enter username that you want to create (eg. client1 or john):"
read u
echo "Specify password that you want the server to use:"
read p
# get the VPS IP
ip=`ifconfig venet0:0 | grep 'inet addr' | awk {'print $2'} | sed s/.*://`
# adding new user
echo "$u * $p *" >> /etc/ppp/chap-secrets
echo
echo "######################################################"
echo "Addtional user added!"
echo "Connect to your VPS at $ip with these credentials:"
echo "Username:$u ##### Password: $p"
echo "######################################################"
else
echo "Invalid selection, quitting."
exit
fi
# Interactive PoPToP install script on a OpenVZ VPS
# Tested on Debian 5, 6, and Ubuntu 11.04
# 2011 v1.1
# Author: Commander Waffles
# http://www.putdispenserhere.com/pptp-debian-ubuntu-openvz-setup-script/
echo "######################################################"
echo "Interactive PoPToP Install Script for OpenVZ VPS"
echo "by Commander Waffles http://www.putdispenserhere.com"
echo "Should work on various deb-based Linux distos."
echo "Tested on Debian 5, 6, and Ubuntu 11.04"
echo
echo "Make sure to message your provider and have them enable"
echo "IPtables and ppp modules prior to setting up PoPToP."
echo
echo "You need to set up the server before creating more users."
echo "A separate user is required per connection or machine."
echo "######################################################"
echo
echo
echo "######################################################"
echo "Select on option:"
echo "1) Set up new PoPToP server AND create one user"
echo "2) Create additional users"
echo "######################################################"
read x
if test $x -eq 1; then
echo "Enter username that you want to create (eg. client1 or john):"
read u
echo "Specify password that you want the server to use:"
read p
# get the VPS IP
ip=`ifconfig venet0:0 | grep 'inet addr' | awk {'print $2'} | sed s/.*://`
echo
echo "######################################################"
echo "Downloading and Installing PoPToP"
echo "######################################################"
apt-get update
apt-get install pptpd
echo
echo "######################################################"
echo "Creating Server Config"
echo "######################################################"
cat > /etc/ppp/pptpd-options <<END
name pptpd
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe-128
ms-dns 8.8.8.8
ms-dns 8.8.4.4
proxyarp
nodefaultroute
lock
nobsdcomp
END
# setting up pptpd.conf
echo "option /etc/ppp/pptpd-options" > /etc/pptpd.conf
echo "logwtmp" >> /etc/pptpd.conf
echo "localip $ip" >> /etc/pptpd.conf
echo "remoteip 10.1.0.1-100" >> /etc/pptpd.conf
# adding new user
echo "$u * $p *" >> /etc/ppp/chap-secrets
echo
echo "######################################################"
echo "Forwarding IPv4 and Enabling it on boot"
echo "######################################################"
cat >> /etc/sysctl.conf <<END
net.ipv4.ip_forward=1
END
sysctl -p
echo
echo "######################################################"
echo "Updating IPtables Routing and Enabling it on boot"
echo "######################################################"
iptables -t nat -A POSTROUTING -j SNAT --to $ip
# saves iptables routing rules and enables them on-boot
iptables-save > /etc/iptables.conf
cat > /etc/network/if-pre-up.d/iptables <<END
#!/bin/sh
iptables-restore < /etc/iptables.conf
END
chmod +x /etc/network/if-pre-up.d/iptables
cat >> /etc/ppp/ip-up <<END
ifconfig ppp0 mtu 1400
END
echo
echo "######################################################"
echo "Restarting PoPToP"
echo "######################################################"
/etc/init.d/pptpd restart
echo
echo "######################################################"
echo "Server setup complete!"
echo "Connect to your VPS at $ip with these credentials:"
echo "Username:$u ##### Password: $p"
echo "######################################################"
# runs this if option 2 is selected
elif test $x -eq 2; then
echo "Enter username that you want to create (eg. client1 or john):"
read u
echo "Specify password that you want the server to use:"
read p
# get the VPS IP
ip=`ifconfig venet0:0 | grep 'inet addr' | awk {'print $2'} | sed s/.*://`
# adding new user
echo "$u * $p *" >> /etc/ppp/chap-secrets
echo
echo "######################################################"
echo "Addtional user added!"
echo "Connect to your VPS at $ip with these credentials:"
echo "Username:$u ##### Password: $p"
echo "######################################################"
else
echo "Invalid selection, quitting."
exit
fi