1.特定用户下通过crontab -e命令编辑crontab任务,比如www
命令应该为:

crontab -e -u www

进入定时任务编辑界面:
701.png

英文键盘, 按【i】进入编辑模式
750.png

写入定时任务规则,比如我这里是给定时任务插件执行脚本

          • /usr/bin/php /home/wwwroot/www.kinmor.com/public/index.php /addons/crontab/autotask/index > /dev/null 2>&1 &

按【ESC】退出编辑模式
907.png
英文键盘,按【:wq】 保存退出

2.常用命令

启动服务

/bin/systemctl restart crond.service 

重新载入配置

/bin/systemctl reload  crond.service  

查看crontab服务状态

/bin/systemctl status  crond.service 

3.crontab相关命令

语法:crontab -u <用户名称> 或 crontab -u <用户名称>

参数:
-e  编辑该用户的计时器设置。
-l  列出该用户的计时器设置。
-r  删除该用户的计时器设置。
-u<用户名称>  指定要设定计时器的用户名称。

命令  svn up

Conflict discovered in 'test.txt'.
Select: (p) postpone, (df) diff-full, (e) edit,
        (mc) mine-conflict, (tc) theirs-conflict,
        (s) show all options:
svn detects that theres a conflict here and require you to take some kind of action.

If you type 's' here you will get a list of the commands and meaning
如果你输入s选项,则会列出所有svn解决冲突的选项,如下所示:

(e) edit - change merged file in an editor #直接进入编辑
(df) diff-full - show all changes made to merged file #显示更改至目标文件的所有变化
(r) resolved - accept merged version of file

(dc) display-conflict - show all conflicts (ignoring merged version) #显示所有冲突
(mc) mine-conflict - accept my version for all conflicts (same) #冲突以本地为准
(tc) theirs-conflict - accept their version for all conflicts (same) #冲突以服务器为准

(mf) mine-full - accept my version of entire file (even non-conflicts)#完全以本地为准
(tf) theirs-full - accept their version of entire file (same) #完全以服务器为准

(p) postpone - mark the conflict to be resolved later #标记冲突,稍后解决
(l) launch - launch external tool to resolve conflict
(s) show all - show this list #显示所有

今天登陆linux服务器 发现var/log下的日志很大 其中包括btmp、message都很大!猜测是被人密码字典猜测后台root了。为规避风险对危险IP进行屏蔽

利用命令进行筛选IP

lastb | awk '{ print $3}' | sort | uniq -c | sort -n

999.png

扩展

将筛选结果导出来 放在home目录下以ips命名

  lastb | awk '{ print $3}' | sort | uniq -c | sort -n > /home/ips.txt

2.删除日志

rm -rf /var/log/btmp

touch /var/log/btmp 

版本:thinkphp5.1

thinkphplibrarythinklogdriverFile.php 148行

问题:最近项目发布到linux系统centos上,Nginx运行的用户是www 而日志 write则变成了root用户 这样www无法读取日志就造成程序错误。linux有严格的权限管理!先根据网上的攻略进行改造!记录如下:

/**
 * 日志写入
 * @access protected
 * @param  array     $message 日志信息
 * @param  string    $destination 日志文件
 * @param  bool      $apart 是否独立文件写入
 * @param  bool      $append 是否追加请求信息
 * @return bool
 */
protected function write($message, $destination, $apart = false, $append = false)
{
    // 检测日志文件大小,超过配置大小则备份日志文件重新生成
    $this->checkLogSize($destination);

    // 日志信息封装
    $info['timestamp'] = date($this->config['time_format']);

    foreach ($message as $type => $msg) {
        $info[$type] = is_array($msg) ? implode("\r\n", $msg) : $msg;
    }

    if (PHP_SAPI == 'cli') {
        $message = $this->parseCliLog($info);
    } else {
        // 添加调试日志
        $this->getDebugLog($info, $append, $apart);

        $message = $this->parseLog($info);
    }
    //解决root产生的日志 www无法访问
    if (!is_file($destination)) {
    $first = true;
    }
    $ret =error_log($message, 3, $destination);
    try {
        if (isset($first) && is_file($destination)) {
            chmod($destination, 0777);
            unset($first);
        }
    } catch (\Exception $e){
    
    }
    return $ret;
}

centos安装iftop

1.安装命令

yum install iftop –y

2.使用直接输入命令

iftop

3.其他使用方法

监控某网卡

iftop -i eth0 -n

显示网卡服务

iftop -i eth0 -n -P

4.常用的参数

-i  设定监测的网卡,如:# iftop -i eth1

-B  以bytes为单位显示流量(默认是bits),如:# iftop -B

-n  使host信息默认直接都显示IP,如:# iftop -n

-N  使端口信息默认直接都显示端口号,如: # iftop -N

-F  显示特定网段的进出流量,如# iftop -F 10.10.1.0/24或# iftop -F 10.10.1.0/255.255.255.0

-h  (display this message),帮助,显示参数信息

-p  使用这个参数后,中间的列表显示的本地主机信息,出现了本机以外的IP信息;

-b  使流量图形条默认就显示;

-f  这个暂时还不太会用,过滤计算包用的;

-P  使host信息及端口信息默认就都显示;

-m  设置界面最上边的刻度的最大值,刻度分五个大段显示,例:# iftop -m 100M

3814.png

5.将命令查询内容以log文件导出

如 将查询ip流量记录导出/tmp/iftop.log文件
iftop -i eth0 -N -P -t -L 50 -s 10 > /tmp/iftop.log