Site icon BASIS GURU

Useful Linux Commands for Database Housekeeping Tasks

LINUX_www.basisguru.com

In today’s article we will see some of the useful Linux commands for repetitive housekeeping work in database systems like:

Let us discuss each case in detail:

List Top X Files By Size :

We can display top files sorted by size using below command :

du -a |sort -n -r |head -n 10

here,

Example:

bash-3.2$ du -a |sort -n -r |head -n 10
8200    .
2584    ./Backup/XI7_BO_SLLPNFFFE_10.0.tpz
2588    ./Backup
2580    ./XI7_11_SAPBO_SLE_10.0_31_00.mf
2572    ./SA10031_0-10005013.mf
212     ./XI6_ELSTER_1.1_01_12.tpz
208     ./ETER2101_12-10004121.sql
20      ./XISFTP_ADAPTER_1.0_05_00.tpz
20      ./SFPTER1004_1-10011814.ZIP
16      ./SLE12123_0-10082636.sql

Counting Files Older Than X Days:

Command:

find -type f -mtime +n |wc -l

Output:

bash-3.2$ find -type f -mtime +1 |wc -l
7

Delete Files Older Than X Days:

Command:

find -type f -mtime +n -exec rm -f {} \

Delete Files Older Than X Hours:

Command:

find -type f -mmin +n -exec rm -f {} \

This command will delete files found by find command forcefully which are older than +n minutes.

Hope you find above Linux commands useful for database admin related activities.

Exit mobile version