Script to keep checking the directory for files.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to keep checking the directory for files.
# 1  
Old 10-29-2017
Script to keep checking the directory for files.

Hello Folks,

Looking for a script which can keep doing ls to the directories and once file landed to the directory then ,read the files do further calculation and exit.

Kindly guide.

Regards,
Sadique
# 2  
Old 10-29-2017
Do not write a long running script; instead create a cron job that runs as frequently as you deem appropriate.
Have the cron job create a lock file when it starts and delete the file when it is complete.
Have the cron job test for the existence of the lock file when it starts, and if present, exit with a message that the previous invocation did not finish normally. It may be that enough files were received that the process time exceeds the cron interval, or it may be that the process has terminated abnormally or stopped waiting for user input.
Make sure that you only process files that have been completely received. Unlike Microsoft operating systems, files appear in 'ls' lists when they are opened not when they are closed.
This User Gave Thanks to jgt For This Post:
# 3  
Old 10-29-2017
In my environment



On every 5 mins the directory have the files ,stay there for 1-2 mins and processed.

I want to write a script which run on every hour for 5 mins to and keep looking for the the if it found then do further calculation as a part of my requirement and exit.


Kindly guide how can i loop ls to the directory and keep checking the files if it found apply the next logic else keep looking till it not found. Once found it should come out of the condition and exit.
# 4  
Old 10-30-2017
This is possibly a duplicate posting to the thread

Script to check the files existence inside a directory.

which already has an answer.
This User Gave Thanks to rovf For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Moving Files one directory to another directory shell script

Hi, Could you please assist how to move the gz files which are older than the 90 days from one folder to another folder ,before that it need to check the file system named "nfs" if size is less than 90 or not. If size is above 90 then it shouldn't perform file move and exit the script throwing... (4 Replies)
Discussion started by: venkat918
4 Replies

2. Shell Programming and Scripting

Checking in a directory how many files are present and basing on that merge all the files

Hi, My requirement is,there is a directory location like: :camp/current/ In this location there can be different flat files that are generated in a single day with same header and the data will be different, differentiated by timestamp, so i need to verify how many files are generated... (10 Replies)
Discussion started by: srikanth_sagi
10 Replies

3. Shell Programming and Scripting

Script for checking files for last hour and send a mail

Hello, I need to write a script to check the files in one folder , if that folder doesn't have files generated from last 1 hr then we need to send mail to particular persons. So Can you please help me to write script to check the files and send email. Thank you.. (1 Reply)
Discussion started by: archana23
1 Replies

4. UNIX for Dummies Questions & Answers

Script for checking the files in a folder

Hi , I am using the below script for checking for a file in a folder. if ; then echo 0 else echo 1 fi Is there any way we can check for files which are starting with GL*.csv.What I am trying to do is , I have to check in a folder for the GL*.csv files if there are any files they I... (6 Replies)
Discussion started by: wangkc
6 Replies

5. Shell Programming and Scripting

Checking directory permissions on UNIX directory

Hi, How do i check if I have read/write/execute rights on a UNIX directory? What I'm doing is checking read access on the files but i also want to check if user has rights on the direcory in whcih these files are present. if then...... And I check if the directory exists by using... (6 Replies)
Discussion started by: chetancrsp18
6 Replies

6. Shell Programming and Scripting

Script should keep checking for availability of files.

Hi, I want my script to check for availability of few files contineously for some time. Lets say from 10:00 AM to 10:30 AM script should keep checking on a particular location for each file one by one. If all the files are available then only it should complete the next processing part, else... (2 Replies)
Discussion started by: amit.mathur08
2 Replies

7. Shell Programming and Scripting

Checking if the files in a directory have a txt extension

foreach file ($dir1/*) if ($file ~ *.txt) then echo "Skipping $file (is a txt file)" endif end that should work right guys? :confused: (15 Replies)
Discussion started by: pantelis
15 Replies

8. Shell Programming and Scripting

Checking the directory and concatenate the data of all the log files in that dir

Hi Gurus, I am new to unix and need your help to make a shell script. I have a requirement, would appreciate if you could please help me on it: Requirement: ------------- I will pass 2 parameters in shell script 1). Directory name say errors 2). file extension say .log First of all this... (4 Replies)
Discussion started by: anshulinpc
4 Replies

9. Shell Programming and Scripting

Checking Files with a Shell Script

Hey everyone, I'm writing a shell script that needs to loop thru a directory and check a defined type of files(.df). I use "checkfile.x" which is a compiled program to check those files. Sintaxis : checkfile.x DatefileName.df The program displays something like this: File: kanswer.df -... (1 Reply)
Discussion started by: Testing_Yorsh
1 Replies

10. Shell Programming and Scripting

Script for checking and reporting file sizes in a directory.

Hi, Need help for a Script for checking and reporting database file sizes in a directory. Request you to please give your valuable inputs. Thanks a lot in advance. Best Regards, Marconi (1 Reply)
Discussion started by: marconi
1 Replies
Login or Register to Ask a Question