Folder Update Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Folder Update Script
# 1  
Old 06-08-2010
Folder Update Script

Hi,

I would like to write a script for send out a notification once a folder has been updated or receive a file.

I have folder with name SOURCE,this folder receiving source files from third party vendor in 24hrs.now i want a notification mail once the folder updated with some thing or once source files has been arived.
# 2  
Old 06-08-2010
To start with try this....

Code:
#!/bin/bash -x

SOURCE=/your/source/directory
B_SOURCE=/your/archive/directory

while true
do
        find $SOURCE -type f -name "*" -mmin +1 -print > /tmp/testfile.txt

        if [ -f /tmp/testfile.txt ]; then
        echo "File Found" | mail -s "File Found" koti_rama@example.com
        for x in `cat /tmp/testfile.txt`
        do
            mv $x $B_SOURCE
        done
        fi
        sleep 60
        rm -rf /tmp/testfile.txt
done

# 3  
Old 06-08-2010
Try this in a cron:

Code:
[ ! -z $(find SOURCE -type f -mtime -1 -print) ] && echo 'Files updated!' | mail -s "Folder Updates" user@domain

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Request for Shell script to move files from Subfolder to Parent folder and delete sub folder

Hi Team, I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder. Eg: parent folder --> /Interface/data/test/IN Sub folder -->/Interface/data/test/IN/Invoice20180607233338 Subfolder will be always with timestamp... (6 Replies)
Discussion started by: srivarun15
6 Replies

2. Shell Programming and Scripting

Shell scripting for moving folder specific files into target directory of that country folder.

I need help to write shell script to copy files from one server to another server. Source Directory UAE(inside i have another folder Misc with files inside UAE folder).I have to copy this to another server UAE folder( Files should be copied to UAE folder and Misc files should be copied in target... (3 Replies)
Discussion started by: naresh2389
3 Replies

3. Shell Programming and Scripting

Script to move one folder to multiple folder...

Hi All, I have to requirement to write a shell script to move file from one folder (A) to another five folder (B,C,D,E,F) and destination folder should be blank. In not blank just skip. This script will run as a scheduler every 2 minutes. It will check number of files in folder A and move 1 to... (9 Replies)
Discussion started by: peekuabc
9 Replies

4. Programming

CGI Perl script to execute bash script- unable to create folder

Hi I have a bash script which takes parameters sh /tmp/gdg.sh -b BASE-NAME -n 1 -s /source/data -p /dest/data/archive -m ARC gdg.sh will scan the /source/data and will move the contents to /dest/data/archive after passing through some filters. Its working superb from bash I have... (0 Replies)
Discussion started by: rakeshkumar
0 Replies

5. Shell Programming and Scripting

How to update folder name after every 2 month

Hello Guru, I need a logic which can rename my folder after every two month with current time stamp... ex: if folder name is My_Folder_20102011 then after two month it should be My_Folder_20122011 its there any way to get it, please share. :confused: Thanks (1 Reply)
Discussion started by: aks_1902
1 Replies

6. Shell Programming and Scripting

File Management: How do I move all JPGS in a folder structure to a single folder?

This is the file structure: DESKTOP/Root of Photo Folders/Folder1qweqwasdfsd/*jpg DESKTOP/Root of Photo Folders/Folder2asdasdasd/*jpg DESKTOP/Root of Photo Folders/Folder3asdadfhgasdf/*jpg DESKTOP/Root of Photo Folders/Folder4qwetwdfsdfg/*jpg DESKTOP/Root of Photo... (4 Replies)
Discussion started by: guptaxpn
4 Replies

7. Shell Programming and Scripting

How to update copyright header on a folder

Hi, I have multiple shell scripts in diffrent folders on server. Most of them contain copyright information like on the third line * Copyright © 2004, 2005, My Inc. All rights reserved. I need to change these headers to * Copyright © 2003, 2009, My Inc. All rights reserved. ... (2 Replies)
Discussion started by: neeto
2 Replies

8. Shell Programming and Scripting

script for Finding files in a folder and copying to another folder

Hi all, I have a folder '/samplefolder' in which i have some files like data0.txt, data1.txt and data2.txt. I have to search the folder for existence of the file data0.txt first and if found have to copy it to some other file; next i have to search the folder for existence of file... (5 Replies)
Discussion started by: satish2712
5 Replies

9. UNIX for Advanced & Expert Users

Auto copy for files from folder to folder upon instant writing

Hello all, I'm trying to accomplish that if a file gets written to folder /path/to/a/ it gets automatically copied into /path/to/b/ the moment its get written. I thought of writing a shell script and cron it that every X amount of minutes it copies these files over but this will not help me... (2 Replies)
Discussion started by: Bashar
2 Replies

10. Shell Programming and Scripting

Shell Script: want to insert values in database when update script runs

Hi , I am new to linux and also also to shell scripting. I have one shell script which unpacks .tgz file and install software on machine. When this script runs I want to insert id,filename,description(which will be in readme file),log(which will be in log file) and name of unpacked folder... (1 Reply)
Discussion started by: ring
1 Replies
Login or Register to Ask a Question