linux 定时任务

来源:互联网 发布:大华视频监控软件 编辑:程序博客网 时间:2024/05/21 19:47

第一步 进入定时任务页面

可以查看本用户的所有定时任务

删除本用户下的所有定时任务

进入数据库

进入某个数据库

查看某个表

查看表结构

咸鱼的代码

## php 代码 db.php
<?phpclass Db {    static private $_instance;    static private $_connectSource;    private $_dbConfig = array(        'host' => '127.0.0.1',        'user' => 'root',        'password' => '',        'database' => 'video',    );    private function __construct() {    }    static public function getInstance() {        if(!(self::$_instance instanceof self)) {            self::$_instance = new self();        }        return self::$_instance;    }    public function connect() {        if(!self::$_connectSource) {            self::$_connectSource = @mysql_connect($this->_dbConfig['host'], $this->_dbConfig['user'], $this->_dbConfig['password']);              if(!self::$_connectSource) {                throw new Exception('mysql connect error ' . mysql_error());                //die('mysql connect error' . mysql_error());            }            mysql_select_db($this->_dbConfig['database'], self::$_connectSource);            mysql_query("set names UTF8", self::$_connectSource);        }        return self::$_connectSource;    }}/*$connect = Db::getInstance()->connect();$sql = "select * from video";$result = mysql_query($sql, $connect);echo mysql_num_rows($result);var_dump($result);*/
## file.php
<?phpclass File {    private $_dir;    const EXT = '.txt';    public function __construct() {        $this->_dir = dirname(__FILE__) . '/files/';    }    public function cacheData($key, $value = '', $cacheTime = 0) {        $filename = $this->_dir  . $key . self::EXT;        if($value !== '') { // 将value值写入缓存            if(is_null($value)) {                return @unlink($filename);            }            $dir = dirname($filename);            if(!is_dir($dir)) {                mkdir($dir, 0777);            }            $cacheTime = sprintf('%011d', $cacheTime);            return file_put_contents($filename,$cacheTime . json_encode($value));        }        if(!is_file($filename)) {            return FALSE;        }         $contents = file_get_contents($filename);        $cacheTime = (int)substr($contents, 0 ,11);        $value = substr($contents, 11);        if($cacheTime !=0 && ($cacheTime + filemtime($filename) < time())) {            unlink($filename);            return FALSE;        }        return json_decode($value, true);    }}$file = new File();echo $file->cacheData('test1');






原创粉丝点击