Quantcast
Channel: PuppyPowered » script
Viewing all articles
Browse latest Browse all 2

WHM / cPanel Cleanup Script

$
0
0

I’m working on a script that cleans up the users home directory. It currently:

  • archives and removes all error_log files it can find
  • removes cpmove.psql directories that are sometimes left in place after a user is moved to another server.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#####################################
# How2 Solutions - http://how2.be
# cPanel Cleanup Script
# version 1.0
#####################################

for user in `ls -A /var/cpanel/users`
do
    echo $user

    #####################################
    # archive error_log
    #####################################
    rm -f /home/$user/error_log.tar
    rm -f /home/$user/error_log.tar.gz

    FILE_LIST=`find /home/$user/public_html -type f -name "error_log"`
    for error_log_file in $FILE_LIST
    do
        echo $error_log_file
        tar -rf /home/$user/error_log.tar $error_log_file
        rm -f $error_log_file
    done

    gzip -f /home/$user/error_log.tar
    chown root:$user /home/$user/error_log.tar.gz

    #####################################
    # remove cpmove.psql
    #####################################
    rm -rf /home/$user/cpmove.psql*
done

I’m planning to custimize this a bit more so error_log files are archived once a month and offer users the ability to disable archiving. More cleanup actions will be added as well. If you think of something usefull to add to this script let me know!


Viewing all articles
Browse latest Browse all 2