Solved

Linux filesystem monitor script

Posted on 2002-05-21
2
530 Views
Last Modified: 2013-11-15
Hi,

Is there a simple script that would periodically check a directory on mapped drive for the presence of a file (we'll call it "createdir.txt")?

Thanks in advance
0
Comment
Question by:cgoldfarb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
haeger earned 400 total points
ID: 7025628
#/bin/sh

file=/somedir/somefile.txt

if [[ -e $file ]]
then
  echo "File exists."
fi

--------------------------------------------------------

Run that (and do check the syntax) with cron at your preferred intervals.

A crontab file consists of lines of six fields each.  The fields are separated by spaces or tabs.  The first five are integer patterns that specify the following:

          minute (0-59),
          hour (0-23),
          day of the month (1-31),
          month of the year (1-12),
          day of the week (0-6 with 0=Sunday).

So, crontab -e should get you into vi where you type something like

* 23 * * * * /somedir/the_above_script.sh
And your filecheck should run 23:00 each day.


.haeger
0
 

Author Comment

by:cgoldfarb
ID: 7025753
Thanks haeger.  Beautiful.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
This article was originally published on Monitis Blog, you can check it here . If you have responsibility for software in production, I bet you’d like to know more about it. I don’t mean that you’d like an extra peek into the bowels of the sourc…
This video demonstrates basic masking and how to edit the mask to reveal the desired image.
XMind Plus helps organize all details/aspects of any project from large to small in an orderly and concise manner. If you are working on a complex project, use this micro tutorial to show you how to make a basic flow chart. The software is free when…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question