-
Notifications
You must be signed in to change notification settings - Fork 257
Auto Delete Log
MrDoobPG edited this page Apr 15, 2019
·
4 revisions
📂 Click Here - Sign up for Google's Suite for Business - Unlimited Space
📂 Click Here - NZB's with from NewsHost - PG Members Receive a 58% Discount
Table of Contents
Today I will tell you how to use this script to blur its tracks and login traces. In advance: any change you make or similar is on a responsibility
The files of logs are in /var/log
tree -u -L 2 /var/log/
tree -u -L 2 /var/log/
/var/log/
├── [root] alternatives.log <---- that`s log file !!
├── [root] apt <---- never delete the folder !!
|
├── [root] fail2ban.log <---- never delete this file !!
├── [root] fu.log <---- that`s log file !!
├── [root] installer <---- never delete the folder !!
|
├── [root] sysstat <---- never delete the folder !!
|
└── [root] unattended-upgrades <---- never delete the folder !!
- su > to root access !
- cd /root/
- nano killop.sh
- add the lines below ( killop.sh )
- CTRG + X
- choma a+x /root/killop.sh
- past this lines
sudo sed -i '$a\*/5 * * * * bash -x /root/killop.sh >/dev/null 2>&1 >/dev/null 2>&1\' /var/spool/cron/crontabs/root
sudo sed -i '$a\@reboot bash /root/killop.sh >/dev/null 2>&1\' /var/spool/cron/crontabs/root
and finish !
[Script]
#!/bin/bash
# settings
# file names to filter
UNWANTED_FILES=(
'vsftpd.log'
'syslog'
'daemon.log'
'kern.log'
'messages'
'syslog'
'lastlog'
'php5-fpm-log'
'user.log'
'faillog'
'fontconfig.log'
'debug'
'dpkg.log'
)
# advanced settings
FIND=$(which find)
FIND_BASE_CONDITION='-type f'
FIND_ADD_NAME='-o -name'
FIND_ACTION=' -delete'
#Folder Setting
#Folder Setting
TARGET_FOLDER=$1'/var/log/'
TARGET_FOLDER=$1'/var/log/'
if [ ! -d "${TARGET_FOLDER}" ]; then
echo 'Target directory does not exist.'
exit 1
fi
condition="-name '${UNWANTED_FILES[0]}'"
for ((i = 1; i < ${#UNWANTED_FILES[@]}; i++))
do
condition="${condition} ${FIND_ADD_NAME} '${UNWANTED_FILES[i]}'"
done
command="${FIND} '${TARGET_FOLDER}' ${FIND_BASE_CONDITION} \( ${condition} \) ${FIND_ACTION}"
echo "Executing ${command}"
eval ${command}
exit 0
You can add more variables if you add the name of the log file in -->
UNWANTED_FILES=( 'name of file'
📂 Click Here - NZB's from USENET Server - PG Members Receive a 60% Discount
Home - https://plexguide.com