forked from HawksRepos/PTS-Team
-
Notifications
You must be signed in to change notification settings - Fork 55
Auto Delete Log
PhysK edited this page Jan 22, 2020
·
1 revision
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-uPTSrades <---- 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'
Wiki - Wiki
- Recommended Pre-Reading
- Server - Storage Planning
- Usenet or BitTorrent
- PTS Editions
- PTS Folder Structure
- PTS-Repos
- Common Issues
Data Transport
- Traefik
- Port Guard
- PTS Shield
- PTS Press
- Google Cloud - GCE
- Hetzner Cloud
- PTS Fork
- Extra PTS Commands
- PTS Vault - Data Storage
- PTSPatrol
- Plex AutoScan in Docker Container
- Plex_Dupefiner
- Traktarr
- System & Network Auditor
- PreInstaller & UnInstaller
Core Apps [Expand]
Community Apps [Expand]
- AirSonic
- Bazarr
- Bitwarden
- BookSonic
- cAdvisor
- Cloud Commander
- Deluge
- DelugeVPN
- Dozzle
- Duplicati
- Filebrowser
- FlexGet
- Gazee
- Headphones
- Heimdall
- HomeAssistant
- jd2-openvpn
- Kitana
- Logarr
- MakeMKV
- MariaDB
- McMyadmin
- MEDUSA
- Mellow
- Miniflux
- Monitorr
- Muximux
- Mylar
- NextCloud
- NowShowing
- NZBHydra2
- Organizr
- plpp
- pyLoad
- qBittorrent
- QBittorrent VPN
- radarrsyncarr
- Resilio
- rflood-openvpn
- rutorrent-openvpn
- Shoko Anime Server
- SpeedTest
- SyncLounge
- Teamspeak3
- The Lounge
- Transmission
- Trakt.or
- Ubooquity
- Varken
- vnc-xfce
- vnstat
- ZeroTier