Limiting the Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Limiting the Script
# 1  
Old 12-05-2012
Limiting the Script

Greetings.

I have script to monitor the disk space of folder it runs every 17 min with help of cron. It sends email when disk size reaches to 85 %. Now the issue is that it continousely generates email until we clear some space in that folder. Is it possible to restrict the Script to send only one alert per an hour even though the cron runs 17 min.

I can use the Disk Quota for this but we dont have permission to enable
only we can monitor the disk space with script only

Last edited by manju98458; 12-06-2012 at 10:18 PM..
# 2  
Old 12-05-2012
Why 17 minutes, not 15?
# 3  
Old 12-05-2012
One way of doing this is to keep track of the time in a file. Just to give you an idea, you can code something like this:-
Code:
CURR_TS=$( date +"%Y%m%d%H" )                       # Current time-stamp
FILE_TS=$( cat curr_ts.txt 2> /dev/null )           # Time-stamp in file

if [ $CURR_TS -eq $FILE_TS ]                        # Checking if current time-stamp & time-stamp in file is matching.
then
      # Do not send email
else
      # Do send email
      echo $CURR_TS > curr_ts.txt                   # Update new time-stamp in file.
fi

# 4  
Old 12-05-2012
concept doesn't work when services is having issue. Just need to limit the alerts to send only one mail per hour instaed of sending multiple emails
# 5  
Old 12-06-2012
Can you explain why you think that this concept does not work in limiting one mail per hour?
# 6  
Old 12-06-2012
cron is running every 17 min, For eg;-if the /apps folder size is reached 85 % in within hour every 17 minutes the alert will generate unless we manually clear some space.
# 7  
Old 12-06-2012
Understood. If you look at the code I suggested above, it is getting the time-stamp with date and hour CURR_TS=$( date +"%Y%m%d%H" ) for each run and writing it to a file only if an alert was send. So next time if the script run within the same hour & try to send an alert, the condition will fail because the CURR_TS & FILE_TS are same and an alert will not be send. Do you still think that this concept does not work?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Limiting access to postqueue

Hi, I have a Debian 6 machine running Postfix 2.7.1. The email server works pretty well. I discovered that any non-root user can access to the mail queue using postqueue command just like root. How can I limit this access? (1 Reply)
Discussion started by: mjdousti
1 Replies

2. Solaris

Limiting Connections from a single IP

I'm looking for a way to limit connections to a Solaris 10 box from any single IP. The problem is that I've had more experience doing this with IPTables on Linux, rather than with IPFilter, which I've found to be somewhat feature-poor. I hope there is some way to do this using IPFilter, I've... (2 Replies)
Discussion started by: spynappels
2 Replies

3. Emergency UNIX and Linux Support

Limiting a user to a script upon login, nothing else.

Hi there, I have a Debian 5.0 server that my company uses for deployment testing. This server needs to be accessed by NOC people that have no NIX knowledge whatsoever. I am creating a bash script for a menu-based command interface for the commands they need to run on their testing routines,... (21 Replies)
Discussion started by: ppucci
21 Replies

4. HP-UX

Limiting SFTP Users While Not Limiting Regular Users?

Hi, I have searched the web and have come back with nothing that is satisfactory for what I require. SFTP is my corporations new file transfer standard. What I require is a method to lock down SFTP users to their directory (they may go to sub directories) while not restricting regular users. ... (2 Replies)
Discussion started by: Emancipator
2 Replies

5. UNIX for Dummies Questions & Answers

SSH keys and command limiting ...

Hi, I've just been trying to setup so that server1 can ssh into server2 and execute a limited set of commands only without password login. I want it also to be able to login with a password if no command given at all though (bit I'm stuck on). I have got this almost working with authorized_keys... (1 Reply)
Discussion started by: moomain
1 Replies

6. HP-UX

limiting failed logins to three

I have tried limiting failed logins to three by the following method logins -ox \ | awk -F: '($8 != "LK" && $1 != "root") { print $1 }' \ | while read logname; do /usr/lbin/modprpw -m umaxlntr=3 "$logname" done /usr/lbin/modprdef -m umaxlntr=3 but it is failing on the 4th... any ideas?... (1 Reply)
Discussion started by: csaunders
1 Replies

7. UNIX for Dummies Questions & Answers

question about limiting the display from the ls command

hey guys im rly new to unix. im attempting to list the 5 largest files in a directory. so i got this far... ls -lR | sort -r and this lists all files by filesize, how can i limit this to only the 5 largest? (4 Replies)
Discussion started by: Aesop
4 Replies

8. UNIX for Advanced & Expert Users

Limiting telnet sessions on HP UX Box

Anyone know how to limit the telnet sessions on a per user basis on an HP UX Box. I would like to limit the Maximum number of telnet seesions a user can open at any give time to around 4 or 5. I have been looking and looking and do not seem to be able to find anything on this. Any help would be... (2 Replies)
Discussion started by: Witlr
2 Replies

9. UNIX for Dummies Questions & Answers

Limiting access

Hi, I'm new to linux and unix, and i have couple of problems: 1) how can i limit the access for a user, for example, i created a user, and i want that this user will be able to be only in one directory, and will see only the files i want him to. 2) I have a domain name, and i want that every... (4 Replies)
Discussion started by: misha
4 Replies
Login or Register to Ask a Question