Solved

Linux filesystem monitor script

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
If your app took Google’s lash recently, here are the 5 most likely reasons.
The viewer will learn how to set up a document for the web and print and the recommended PPI for printing.
This video demonstrates how to use each tool, their shortcuts, where and when to use them, and how to use the keyboard to improve workflow.

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now