Sponsored Content
Top Forums Shell Programming and Scripting Monitoring a file - Basic Bash Question Post 302414704 by Nolan- on Tuesday 20th of April 2010 08:17:42 PM
Old 04-20-2010
Java Monitoring a file - Basic Bash Question

*This is not homework I am new to UNIX and want to try this Monitoring a file demo*
*If this is the wrong forum please move it - im new to the forums*

$1 = the file to be monitored
$2 = the time for the file to sleep

If the file gets changed (using -nt) it will send my username mail saying its changed it. The problem im having is it goes into an endless loop, im just learning the while loop so im guessing its that. Also I dont understand the whole mail code - how do I input subject and stuff.

Code:
#!/bin/bash
if [ $# -eq 0 ] ; then
    echo "enter <file> <time>"
exit 1
fi

if [ ! -e $1 ] ; then
    echo " please enter an existing file"
exit 2
fi

if [ "$2" = "" ] ; then
    echo " no argument 2"
exit 3
fi

if [ $2 -lt 10 ] ; then 
    echo " please enter a number higher than 10"
exit 4
fi

while [ $2 -ge 10 ] ; do
if [ $1 -nt ] ; then
    sleep $2
    mail $LOGNAME
else
    echo "file unchanged"
fi
done
exit 0




 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

basic question

hey...when i type who...what does "pts" field mean??? eg pts 0 etc (1 Reply)
Discussion started by: urwannabefriend
1 Replies

2. UNIX for Dummies Questions & Answers

Really basic question....

Hello all. Let me start off by saying I know a little more then it seems by me asking this question... here goes I have an old 486 box and I want to start messing around with unix. I've been taking classes for 3 or 4 years in c programming in unix, so I am used to the commands and such, but I... (1 Reply)
Discussion started by: robherms
1 Replies

3. Shell Programming and Scripting

Basic bash 'for loop' usage

Hi! I have a simple question about using a for loop. I'm trying to open up all the zip files in the currect directory with ark, but I am getting the error "bash: syntax error near unexpected token `for $i ; do ark $i ; done ; I looked in the info pages for bash, but I can't seem to figure... (2 Replies)
Discussion started by: Orange Stripes
2 Replies

4. UNIX for Dummies Questions & Answers

Basic Unix bash script help

Hello there Been using Unix bash scripting for two days now so am very new to this. I am currently doing a project now and i'm basically making a noughts and crosses game (or tic tac toe). I have created the board using an array. When I try and check to see if the array is empty using an If... (3 Replies)
Discussion started by: ChrisHoogie
3 Replies

5. Solaris

basic question on sd.conf and lpc.conf file

Hello Guys, Do we need to configure this file only if we add SAN disk or even if we add local disk, do we need to modify? (4 Replies)
Discussion started by: mokkan
4 Replies

6. UNIX for Dummies Questions & Answers

Basic file processing question

I have a csv file with 3 columns. Column 1 is a date "mm/dd/yyyy", column 2 is a dollar amount (e.g. "100.00") & column 3 in a description of where the transaction took place (e.g. "CHECK CRD PURCHASE 10/07 ACME INC USA") so... "10/01/2009","100.00", "CHECK CRD PURCHASE 10/07 ACME INC USA" I... (1 Reply)
Discussion started by: watingo
1 Replies

7. Shell Programming and Scripting

Basic line reading and file merge question

No doubt these questions have been answered many times, but I struggled to find them - sorry. 2 questions: 1. I wish to read in a file one line at a time and do 'stuff' with it, such as: file="tst2" while IFS= read -r line do echo `wget -qO -... (3 Replies)
Discussion started by: Golpette
3 Replies

8. Shell Programming and Scripting

Basic bash, echo in loop for

Hi, I am trying to make a script to manage log. I want to write the name of the .gz I moved and the date : for i in `ls $replog/*.gz` do echo " $i " `echo $i date +%d:%m:%Y` `echo $datee `>> $replog/mrnet.log mv $i /var/log/vieux-logs done I need to echo... (10 Replies)
Discussion started by: Dabless
10 Replies

9. Shell Programming and Scripting

Help in making a basic bash script

Hi All, I am trying to monitor CPU load of few processes, with the same name. The output that I get from top is the following 28171 root 20 0 1089m 21m 3608 S 103 0.3 15:16.89 /opt/ppp//h264rtptranscoder.bin --videoPort=14504 --audioPort=14505 27589 root 20 0 1060m 23m... (3 Replies)
Discussion started by: liviusbr
3 Replies

10. Solaris

Basic question regarding root file system copy to another disk

Hello, I am creating a new disk using the following command: dd if=/dev/zero of=/export/home/ramdisk/0 bs=512 count=4096k after creating the disk, i tool a ufsdump of a solaris 10 filesytem (disk size 512MB) ufsdump -cvf /export/home/ufsdump/sol_orig /and then restored the dump files onto... (10 Replies)
Discussion started by: Zam_1234
10 Replies
kcmond(1M)																kcmond(1M)

NAME
kcmond - EMS Kernel Tunable Monitor daemon SYNOPSIS
kcmond DESCRIPTION
The kcmond daemon monitors the consumption of kernel resources. It is an Event Monitoring Services (EMS - see ems(5)) monitor. The data collected by kcusage can be displayed by kcusage(1M). kcmond includes a resource dictionary file (/etc/opt/resmon/dictionary/kcmond_01.dict) which is used by EMS to identify resources for moni- toring. Users can control the monitoring of each kernel tunable by setting a percentage value for the consumption of that resource. For example, if the user sets a value of 75 for nproc, the Kernel Tunable Monitor will report an event when the number of processes reaches 75% of the nproc setting. The kcalarm(1M) command is used to add, modify and delete kernel tunable alarms. The kcusage(1M) command is used to view data collected by kcmond. The kcweb(1M) command provides a Web-based, graphical user interface to control alarms and view usage data, including graphs of the usage data. kcmond is a light weight daemon that will exit after being idle for ten minutes. SUPPORTED PARAMETERS
For a complete list of the kernel tunables that can be monitored with this daemon, see the kcusage(1M) manpage. DEPENDENCIES
kcmond must be run by the registrar process of the Event Monitoring Service (EMS) and is not designed to be run from the command line. AUTHORS
was developed by Hewlett-Packard. FILES
Executable. The resource dictionary for kcmond, describes the location (e.g. /system/kernel_tunables/nproc) of kernel tunables in the resource hierar- chy and references kcmond as the resource monitor. Log file for the entire Resource Monitor Framework, including kcmond. Any errors are logged here. SEE ALSO
kcalarm(1M), ems(5), kcusage(1M) kcmond(1M)
All times are GMT -4. The time now is 09:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy