Author: jpuyy

  • PHP message: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted

    今天在用某程序生成html文章的时候,到46%的时候页面空白了。

    首先就是查nginx的日志

    2012/11/18 22:01:02 [error] 11485#0: *66546 FastCGI sent in stderr: “PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 71 bytes) in ….

    网上一查,才发现设定的值偏小了,到php.ini查找,466行处

    memory_limit = 128M

    改为256M后,重新生成html,没有问题了。

    昨天刚学了vim的一个技巧:将光标定位在128上,按住ctrl+a,数字变大,这次正好用上了。(数字减小,按ctrl+x)

    另一种方法是修改程序,不建议这样操作。

    具体说明在:http://www.php.net/manual/en/ini.core.php#ini.memory-limit

    要设置不限制,则值为-1

     

  • linux中pkill,kill,killall的用法

    killall也可以跟进程名

    killall – kill processes by name

    killall sends a signal to all processes running any of the specified commands. If no signal name is specified, SIGTERM is sent.

    kill 是要据进程号来杀死进程,加-9强制杀死

    结合ps 或 pgrep

    pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria to stdout. All the criteria have to match. For example,

    $ pgrep -u root sshd

    will only list the processes called sshd AND owned by root.

    但是这样只会显示进程号,怎么办? 永远不要忘了man一下

    man pgrep里给出了实例

    我试了一下,如

    ps `pgrep -u www-data` 或者 ps $(pgrep -u www-data) 可以查看到详细的属于www-data用户的进程

    root@debian:~# ps `pgrep -u www-data`
    PID TTY STAT TIME COMMAND
    3128 ? S 0:00 : worker process
    12245 ? S 0:04 php-fpm: pool www
    12246 ? S 0:04 php-fpm: pool www
    12247 ? S 0:05 php-fpm: pool www
    12248 ? S 0:06 php-fpm: pool www
    12249 ? S 0:05 php-fpm: pool www
    12250 ? S 0:05 php-fpm: pool www

  • vim光标移动

    将光标移到指定列,输入 数字+| ,例如 77|

    向右移动指定数量字符,输入 数字+l(小写L) ,例如 5l
    向左移动指定数量字符,输入 数字+h(小写H) ,例如 8h

    移动光标到上一个单词首字母,输入 b
    移动光标到下一个单词首字母,输入 w

    移动光标到行首,按0
    移动光标到行尾,按$

    移动光标到指定行行首,例如12行行首:12G 或 :12回车
    首行行首:gg
    最后一行行首:G

    向下移两行: 2+或2j
    向上移两行: 2-或2k

    移动到上一句:)
    移动到下一句:(

    移动到上一段:{
    移动到下一段:}

    在(),{},[],<>中移动光标,当光标在上述四种之内时,按%跳到开始,再按%跳到结尾。在编辑配置文件的时候非常有用。

    在屏幕中移动光标:
    移动到屏幕的最上端:H
    移动到距屏幕最上x行: xH
    移动到屏幕中央:M
    移动到屏幕底部:L
    移动到距屏幕底部x行:xL

    向下(前)滚动:ctrl + f
    向上(回)滚动:ctrl + b

    滚动到下一屏的中央: ctrl + d
    滚动到上一屏的中央: ctrl + u

    移动光标到屏幕中央(并把当前行带到屏中央,与M略有不同),小写字符:zz
    将当前行置于屏幕顶端 zt
    将当前行置于屏幕底端 zb

    行不动,整个文档向上移 ctrl + e
    整个文档向下移 ctrl + y

  • linux beep蜂鸣声

    公司搬家得到一台老IBM笔记本,各种折腾,今天折腾一下蜂鸣声。

    有时候按tab补全,vim输入错误等都会听到这样的报警声,很难听,如果想关掉它,

    临时关闭

    debian:

     $sudo rmmod pcspkr

    centos以root执行

     #rmmod pcspkr

    永久关闭

    debian:

     $sudo echo "blacklist pcspkr" >> /etc/modprobe.d/blacklist

    centos以root执行:

     #echo "alias pcspkr off" >> /etc/modprobe.conf

    不关闭就可以用beep来做一些有意思的警告了,甚至把警告变为music

    apt-get install beep

    加载驱动:

     modprobe pcspkr

    通过beep来操作(会听到嘀一声):

     beep -f 1000

    以下“音乐”摘自
    http://kirrus.co.uk/2010/09/linux-beep-music/

    beep -f 1000 -n -f 1500 -n -f 600 -n -f 500 -n -f 100 -r 2 -l 10 -n -f 50 -r 2 -l 200 -n -f 40 -r 2 -l 300 -n -f 60 -r 3 -n -f 50 -r 3

    星球大战的经典铃声:

    beep -l 350 -f 392 -D 100 -n -l 350 -f 392 -D 100 -n -l 350 -f 392 -D 100 -n -l 250 -f 311.1 -D 100 -n -l 25 -f 466.2 -D 100 -n -l 350 -f 392 -D 100 -n -l 250 -f 311.1 -D 100 -n -l 25 -f 466.2 -D 100 -n -l 700 -f 392 -D 100 -n -l 350 -f 587.32 -D 100 -n -l 350 -f 587.32 -D 100 -n -l 350 -f 587.32 -D 100 -n -l 250 -f 622.26 -D 100 -n -l 25 -f 466.2 -D 100 -n -l 350 -f 369.99 -D 100 -n -l 250 -f 311.1 -D 100 -n -l 25 -f 466.2 -D 100 -n -l 700 -f 392 -D 100 -n -l 350 -f 784 -D 100 -n -l 250 -f 392 -D 100 -n -l 25 -f 392 -D 100 -n -l 350 -f 784 -D 100 -n -l 250 -f 739.98 -D 100 -n -l 25 -f 698.46 -D 100 -n -l 25 -f 659.26 -D 100 -n -l 25 -f 622.26 -D 100 -n -l 50 -f 659.26 -D 400 -n -l 25 -f 415.3 -D 200 -n -l 350 -f 554.36 -D 100 -n -l 250 -f 523.25 -D 100 -n -l 25 -f 493.88 -D 100 -n -l 25 -f 466.16 -D 100 -n -l 25 -f 440 -D 100 -n -l 50 -f 466.16 -D 400 -n -l 25 -f 311.13 -D 200 -n -l 350 -f 369.99 -D 100 -n -l 250 -f 311.13 -D 100 -n -l 25 -f 392 -D 100 -n -l 350 -f 466.16 -D 100 -n -l 250 -f 392 -D 100 -n -l 25 -f 466.16 -D 100 -n -l 700 -f 587.32 -D 100 -n -l 350 -f 784 -D 100 -n -l 250 -f 392 -D 100 -n -l 25 -f 392 -D 100 -n -l 350 -f 784 -D 100 -n -l 250 -f 739.98 -D 100 -n -l 25 -f 698.46 -D 100 -n -l 25 -f 659.26 -D 100 -n -l 25 -f 622.26 -D 100 -n -l 50 -f 659.26 -D 400 -n -l 25 -f 415.3 -D 200 -n -l 350 -f 554.36 -D 100 -n -l 250 -f 523.25 -D 100 -n -l 25 -f 493.88 -D 100 -n -l 25 -f 466.16 -D 100 -n -l 25 -f 440 -D 100 -n -l 50 -f 466.16 -D 400 -n -l 25 -f 311.13 -D 200 -n -l 350 -f 392 -D 100 -n -l 250 -f 311.13 -D 100 -n -l 25 -f 466.16 -D 100 -n -l 300 -f 392.00 -D 150 -n -l 250 -f 311.13 -D 100 -n -l 25 -f 466.16 -D 100 -n -l 700 -f 392

    –add by jpuyy@2013年03月20日

    解决linux播放音乐不出声的问题

    想用这台老本放音乐,但是每次都不出声,安装好了alsa,使用lsmod查看能看到声卡。困扰很久,后来查到一篇文章,http://xghe110.blog.51cto.com/337884/65713 查到原来alsamixer默认是不出声的。

    解决方法:

    1. root用户输入 #alsamixer,在界面中,左右方向键选择声道,上下方向选择大小。(关键)按m打开对应的声道。

    2. 输入# alsactl store 保存当前的配置。

    3. 在/etc/rc.local中加入 alsactl restore,下次重启后自动载入当前的alsa配置。

    这时,通过mpg321,mplayer,mocp来播放音乐。

  • 编辑~/.vimrc使tab变为4个空格

    在.vimrc中(如果没有请新建)添加以下代码后,重启vim即可实现按TAB产生4个空格(注:ts是tabstop的缩写,设TAB宽4个空格):

    set ts=4
    set expandtab

    对于已保存的文件,可以使用下面的方法进行空格和TAB的替换:
    TAB替换为空格:

    :set ts=4
    :set expandtab
    :%retab!

    空格替换为TAB:

    :set ts=4
    :set noexpandtab
    :%retab!

    加!是用于处理非空白字符之后的TAB,即所有的TAB,若不加!,则只处理行首的TAB。

    注意:
    如果 vimrc 里有 set paste 设置的话会有冲突,使上面的配置不生效。

  • linux挂载ntfs提示read-only

    公司搬家,挖出一台很老的IBM A23,256MB内存,10GB硬盘。费了不小力气装了一个debian,这么老的机器当然要用光盘装了,期间网卡不能识别,安装了firmware-linux-nonfree_0.28+squeeze1_all.deb。

    装好之后,越发感觉linux的强大。

    接上网线,打算用rtorrent下PT,并挂载一个320GB的移动硬盘,挂载有问题,只能用read-only挂载。

    网上搜到linux挂载须使用ntfs-3g的软件,安装ntfs-3g

    apt-get install ntfs-3g

    之后使用如下命令挂载

    mkdir /mnt/usb
    mount -t ntfs-3g /dev/sdb1  /mnt/usb -o defaults,umask=0