Skip to content

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

  1. Intro
  2. The Script

1. Intro

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 !!


2. The Script

  1. su > to root access !
  2. cd /root/
  3. nano killop.sh
  4. add the lines below ( killop.sh )
  5. CTRG + X
  6. choma a+x /root/killop.sh
  7. 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

Installing PlexGuide

  1. PlexGuide Install Information

Preplanning & Information

  1. PG Folder Structure

Domain and Port Control

  1. CloudFlare Tunnel

Primary Applications

  1. Plex

Useful Links

  1. PG YouTube Channel
Clone this wiki locally