Solved

Linux filesystem monitor script

Posted on 2002-05-21
2
527 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
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
unzipping a password protected zip file without zipping tool (winzip) 18 100
error log using ftp 7 56
Run Secure WMI query from CentOS 5 80
IP 10.0.1.2 / 255.0.0.0 61 56
Workplace bullying has increased with the use of email and social media. Retain evidence of this with email archiving to protect your employees.
Fine Tune your automatic Updates for Ubuntu / Debian
Using Adobe Premiere Pro, the viewer will learn how to set up a sequence with proper settings, importing pictures, rendering, and exporting the finished product.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

809 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