LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-23-2009, 11:04 AM   #1
elainelaw
Member
 
Registered: Jan 2008
Posts: 258

Rep: Reputation: 30
check file


can advise how to write a shell script to do that :

if the file ( the file name is /tmp/my_file ) is exist and this file is elder than 12 hours , then send me alert mail to inform me , if this file not exist , then do nothing .

Thx in advance.
 
Old 10-23-2009, 11:51 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,916

Rep: Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689
Quote:
Originally Posted by elainelaw View Post
can advise how to write a shell script to do that :

if the file ( the file name is /tmp/my_file ) is exist and this file is elder than 12 hours , then send me alert mail to inform me , if this file not exist , then do nothing .

Thx in advance.
Spell out your words, please.

Read the man page for the 'find' command, Pay particular attention to the "atime", "ctime", and "mtime" options. That will let you find the files based on your criteria.

And post what you've written so far and where you're getting stuck, and we can help. Otherwise, there are lots of bash scripting tutorials out there that can help you.
 
Old 10-29-2009, 05:27 AM   #3
elainelaw
Member
 
Registered: Jan 2008
Posts: 258

Original Poster
Rep: Reputation: 30
I know how to use find , can advise how to do the rest part ? thx in advance.

find dir -name /tmp/my_file -cmin +720 -exec ls {} \;
 
Old 10-29-2009, 11:30 AM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,916

Rep: Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689
Quote:
Originally Posted by elainelaw View Post
I know how to use find , can advise how to do the rest part ? thx in advance.

find dir -name /tmp/my_file -cmin +720 -exec ls {} \;
Again, SPELL OUT YOUR WORDS. It's "thanks", not "thx"...

And if you know how to use find to get what you need, then look up the mail command, and some bash scripting tutorials from Google.

If you have problems, post them, along with what you've written.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
not able to check the file is in use or not p_raju Linux - General 3 07-01-2008 05:23 AM
How to write crontab to check file size and all file in a directory? modpriest Linux - Newbie 1 02-14-2008 07:48 AM
c++ check if file exists Genjix Programming 3 03-15-2004 01:08 AM
Boot disk; check. CD in drive; check. Doesn't work; check. Hal DamnSmallLinux 7 02-04-2004 03:10 AM
check file in use pangfai Linux - Networking 1 07-09-2002 02:29 PM


All times are GMT -5. The time now is 08:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration