Such a script is really dangerous and it should contain code to stop it running on any Operating System Partition and anywhere which legitimately has large files. Taking the filesystem as a user-supplied parameter is asking for trouble.
The script comment says "Program to find the disk space and to delete the older files". There is no code in the script which looks at the age of the files, but there is code to look at the size of individual files.
I can't vet Perl code, but the unix commands look iffy.
This find command has a lot wrong with it.
It needs -xdev to confine the scope to one filesystem.
It needs -type f to just look at files.
There is a Shell redirect in the middle of the arguments.
The size range needs escaped brackets or only the second value will be taken into account.
The size range is very strange. It equates to 5 Megabytes to 10 Megabytes.
Test the script with an echo not a direct rm command !
The delimiter between fields is not a single space, it is multiple spaces.
You probably mean something like:
I believe that both Operating Systems have df -Pk and could produce the same format of output.
Last edited by methyl; 06-11-2012 at 06:03 PM..
Reason: typo
hello,
I have to check the free space on the disk that would work both on Windows and Unix platform e.g on C: \ for Windows and / on Unix. I could use Unix command 'df ' ( my windows system has Unix emulator cygwin and could run 'df ' as well).
But I'd like not to rely on system command but... (1 Reply)
Hi,
I am trying to write a shell script to delete logs generate by db when space in the folder reaches 70%. i am getting space values from db, find the files at OS and remove them by using a cron job runs every 5minutes.
I have to keep the latest 5 files at any time, my problem is that log files... (3 Replies)
Hello,
Can anybody please tell me the command to find out the filesystem or a file which is consuming larger disk space sing i want to find out the file and want to compress it
please help me out
any help would be appreciated (6 Replies)
Some times my disk space is used upto 100% due to the application logs .
So this script is to monitor the disk space usage and wall message to the users about the disk space usage if it exceeds the limit set in the script. Here for example the limit is set to 80%. This job is added in cron to... (2 Replies)
Hi all,
FreeBSD7.1 @ sh.
In a backup script I am trying to get the blocks used by the backup once completed.
I am using the function:
#!/bin/sh
spaceused()
{
du -d 0 "${1}" | awk -F"+" '{ print $1 }
}
to return the blocks used of said directory and contents.
Via. command line... (7 Replies)
Issue with disk space usage
I have the following line in my "df -h" output:
Filesystem Size Used Avail Capacity Mounted on
/dev/ad4s1a 496M 495M -39M 109% /
What is the issue with having 9% excess utilisation? How can I find out what this partition is... (2 Replies)
Given this directory /web
I need to get the current usage (in %) on Linux and Unix both using the same command on bash shell ?
The command i tried was working on Unix (solaris) but does not filter the desired same value when run of Linux.
My command df -h /web | awk '{print $5}' | sed -n... (5 Replies)