is_writeable() 函数判断指定的文件是否可写。

该函数是 is_writable() 函数的别名。

语法

is_writeable(file)

说明
如果文件存在并且可写则返回 true。file 参数可以是一个允许进行是否可写检查的目录名。



<?php
$file = "test.txt";
if(is_writeable($file))
  {
  echo ("$file is writeable");
  }
else
  {
  echo ("$file is not writeable");
  }
?>

Tags: ,
PHP 内置函数 file_put_contents 用于写入文件。

file_put_contents 函数最简单的写法,可以只用两个参数,一个是文件路径,一个是要写入的内容,语法如下:

file_put_contents(filepath,data)
如果文件不存在,file_put_contents 函数会自动创建文件;如果文件已存在,原有文件被重写。

你可以利用 file_put_contents 函数创建并写入一个新文件,或者重写一个原有文件。

下面是一个使用 file_put_contents 函数的 PHP 代码示例:

linux smartd启动失败 不指定

jed , 2009-4-9 10:40 , 服务器技术 , 评论(0) , 阅读(3693) , Via 本站原创
smartd是一个守护进程(一个帮助程序),它能监视拥有自我监视,分析和汇报技术(Self-Monitoring,

Analysis, and Reporting Technology - SMART)的硬盘。

SMART系统使得硬盘能监视并汇报自己的运行状况。它的一个重要特性是能够预测失败,使得系统管理员

能避免数据丢失。

smartd由kernel-utils包缺省安装。用命令 rpm -ql kernel-utils 可以列出kernel-utils包中的文件。

smartd守护进程通常在系统启动的时候被开启,它的配置文件是/etc/smartd.conf。

比如,假设有两个硬盘被安装,/dev/hda和/dev/hdb。一个是CD_ROM设备,另一个是硬盘。为了检测它们

是否支持SMART,使用命令 smartctl -i /dev/hda 和 smartctl -i /dev/hdb:


# /usr/sbin/smartctl -i /dev/hda
smartctl version 5.1-11 Copyright (C) 2002-3 Bruce Allen
Home page is http://smartmontools.sourceforge.net/

=== START OF INFORMATION SECTION ===
Device Model: ST380011A
Serial Number: 3JVB672N
Firmware Version: 8.01
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: 6
ATA Standard is: ATA/ATAPI-6 T13 1410D revision 2
Local Time is: Fri Aug 20 14:09:16 2004 EST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

”SMART support is: Available - device has SMART capability.“这行说明支持SMART。"SMART

support is: Enabled”这行说明SMART已经被打开。

CD-ROM设备和旧式的硬盘不支持SMART,这可以从smartctl -i /dev/hdb的输出看出:

# /usr/sbin/smartctl -i /dev/hdb
smartctl version 5.1-11 Copyright (C) 2002-3 Bruce Allen
Home page is http://smartmontools.sourceforge.net/

=== START OF INFORMATION SECTION ===
Device Model: LTN526D
Serial Number: [No Information Found]
Firmware Version: 9S03
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: 1
ATA Standard is: Exact ATA specification draft version not indicated
Local Time is: Fri Aug 20 14:24:43 2004 EST
SMART is only available in ATA Version 3 Revision 3 or greater.
We will try to proceed in spite of this.
SMART support is: Unavailable - device lacks SMART capability.
A mandatory SMART command has failed: exiting. To continue, use the -T
option to set the tolerance level to 'permissive'

注意有些硬盘控制器不支持SMART。比如有些硬件RAID控制器不支持,或者不会传递SMART信息,即使加入

的硬盘支持SMART。

chkconfig --del smartd

在服务里面停掉smartd服务守护进程。这是一个硬盘是否有故障的监视进程,

shell# service smartd start
启动 smartd: [失败]

shell# service smartd status
smartd 已死,但是 subsys 被锁

Tags: ,
复制字段里的数据命令:



UPDATE table SET 被替换的字段名=被复制的字段名  



演示如下



UPDATE dede_archives SET senddate=pubdate




如何手动将同一数据表内不同字段之间的内容批量转换,可以参考下面的命令:



UPDATE table set 字段名=REPLACE(字段名,'原字符串','替换的字符串') where 已知的字段名 LIKE '%原字符串%'  



应用到本文实例



UPDATE pw_members set yz=REPLACE(yz,'1','2') where yz LIKE '%1%'

分页: 1/1 第一页 1 最后页 [ 显示模式: 摘要 | 列表 ]