473,698 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Monitor a folder. no activity for 1 hour, send an email

154 New Member
Hi I am trying to do a script to monitor a dir where files pass through approx every 5 mins but sometimes files may not come in for hours

So the purpose of the script is to monitor by if no files pass through in 1 hour send an email.

So was thinking to use the shell command to grab the time when a file comes in and write to a txtfile.
Now when the files keep coming it will overwrite the old time.
Now if no new files are coming in an hour i got the old time but i having trouble calculating the hour so to trigger out to send an email

this is what i came up with so far

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2. #Purpose to monitor a folder
  3.  
  4. my $IN = "TIMEFILE1";
  5. my $IN2 = "TEST";
  6.  
  7. my $srcdir = "/home/tibco/javastuff/test";
  8. my $tfile = "/home/tibco/scripts/time.txt";
  9. my $tfile2 = "/home/tibco/scripts/time2.txt";
  10.  
  11. open (OUT ,">$tfile") || "Could not open file $!";
  12. open (FILE, ls -lt | awk -F" " '{print $8}');
  13. while (<FILE>) {
  14.     #print $_;
  15.     print OUT "$_";
  16.     #print $_;
  17. }
  18. close OUT;
  19. close FILE;
  20. ###### get system time
  21. open (SYSTEM ,">$tfile2") || "Could not open file $!";
  22. open (FILE2, date | awk -F" " '{print $4}');
  23. while (<FILE2>){
  24.     #print $_;
  25.     print OUT "$_";
  26.     #print $_;
  27. }
  28. close SYSTEM;
  29. close FILE2;
  30.  
  31. #END
May 18 '07
11 3018
jonathan184
154 New Member
thank you for your help guys.
May 22 '07 #11
KevinADC
4,059 Recognized Expert Specialist
Personally I don't see how the code will know if a file was new in the dir within the last hour. All it seems to do is check if there is a file with DWH in the filename.
May 22 '07 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

6
342
by: Kalyan | last post by:
Hi I need some idea, Is there any way to write vb code to monitor server activity and if server fails send out email to admin. thanks Kalyan
1
1263
by: chris | last post by:
Is there a way that i can monitor the use of a file in terms of a timestamp? My goal is to monitor the activity of a file and when it goes beyond 10 minutes of non activity I will shut it down.
1
4337
by: Roger | last post by:
I currently have an application that can monitor the Inbox of one mailbox running on a client using Outlook 2003. This is a standalone application that needs Outlook to be running in order to see all mail coming into the e-mail box. This is using Interop.Outlook Example of code... Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
4
2386
by: John | last post by:
I'd like to write a programme that runs on a PC with two monitors. The application would be used in a shop, with one monitor for shop assistant and the other for the customer. The two must show things independently, so the application can display certains things on one monitor (eg goods in the store) and certain other things on the other monitor (eg details of a certain product). Is this possible?
4
6159
by: Raj | last post by:
Can we create an event monitor for statements in a partitioned environment? CREATE EVENT MONITOR stmt_event FOR STATEMENTS WRITE TO FILE '/home/rajm/event' ON PARTITION 0 GLOBAL DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returned:
2
5941
by: Hemant Shah | last post by:
Folks, I have several files in db2event/db2detaildeadlock directory and is using up considerable amount of disk space. When I run following command I see event for 2 years ago. db2evmon -db dbname -evm db2detaildeadlock How do I clear old event and reduce disk usage?
6
6828
by: wugon.net | last post by:
Hi , Anyone know how to monitor db2 trigger activity ? We suffer some trigger issue , and we try to monitor trigger's behavior use event monitor and db2audit, but both tools can not get trigger's sql statment and cost, have other tools can get trigger's executing sql statment and cost ? our test case as follow: Env:
0
2628
by: wugon.net | last post by:
Hi , Anyone know how to monitor db2 trigger activity ? We suffer some trigger issue today and we try to monitor trigger's behavior use event monitor and db2audit, but both tools can not get trigger's sql statment and cost, have other tools can get trigger's executing sql statment and cost ? our test case as follow: Env:
1
1464
by: jonathan184 | last post by:
how to monitor and find out if files test1_* and test2_* files were sent in an hour and if not send an email This is on a unix system basically I got a cronjob that runs every sec polling a ftp dir which name dir1 and transfers the file to another server So there are two types of files i want to check if are coming through and if they did not come through in an hour send an email. so files test1_* and test2_* I am checking for. Could...
0
8608
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9161
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8897
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8867
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7732
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6522
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
2332
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2006
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.