Conditional File Movement script scheduled using CRON job


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Conditional File Movement script scheduled using CRON job
# 1  
Old 09-17-2005
Conditional File Movement script scheduled using CRON job

Hi All,
i am trying to automate a process and have to create a unix script like wise. I have a scenario in which i need to automate a file movement. Below are the steps i need to automate.

1. Check whether a file (Not Fixed name-Pattern search of file say 'E*.dat') is present in a directory /hm/srcfiles. In this directory, there will be files placed by a JSP on adhoc basis like E1.dat,E2.dat,E3.dat ......
2. A script/Job keeps sniffing this directory for files of this kind.... the moment it finds one, it should transfer the file to other directory say /hm/tgt but with renaming it to 'FILE.dat'. This transfer is conditional, the file movement should happen only if the /hm/tgt directory does not contain 'FILE.dat', and if 'FILE.dat' is present, it should wait and try to move the file again untill succeded.
3.The cleanup of file 'FILE.dat' from /hm/tgt/FILE.dat happens by another shell script called by a different application. I am kind of able to write that (I have not worked with unix scripting much Smilie )
4.I guess CRON job scheduling should be used for triggering the file movement script, correct me if i am wrong.
5.This CRON job should run contineously and trigger the script when ever the
file named like 'E*.dat' arrives. Also if many files are present in /hm/src directory, all the files should be processed sequentially Smilie

Thanks for the patience to read the explaination. I do not know scripting much OR have used CRON job scheduling before. Can someone help me in this regard. I a sound too naive with UNIX, it is because i am Smilie
# 2  
Old 09-19-2005
Hi,

First, create a shell named "toto.sh" and doing following commands :
if [ -f /hm/srcfiles/E*.dat ]
then
mv /hm/srcfiles/E*.dat /hm/tgt
...
fi

Second, edit cron daemon
crontab -e

Third, in crontab put "toto.sh" with this parameters for exemple :
* 7-22 * * 1-5 <PATH>/toto.sh 1>/dev/null 2>&1
(execution between 7am and 10pm, from monday to friday)

Rgds.
# 3  
Old 09-20-2005
SCHEDULED USING tHREAD

WHAT THE PREVIOUS IS CORRECT BUT INSTEAD OF SPECIFIYNG IN THE CRONTAB - e go for /etc/crontab and specify there
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Cron job scheduled is running once, but reports are generating twice

Team, Hope you all are doing fine I have one admin server which is being used dedicately to run cron jobs on hourly basis, fetching the details from Database which is in a different server.These cronjob are run on every hourly/5 minutes basis depending as per end user requirement.The script... (12 Replies)
Discussion started by: whizkidash
12 Replies

2. Shell Programming and Scripting

Scheduled job not running automatically in crontab

i have a job scheduled in crontab. The problem is, it is not running automatically as per the time scheduled. But runs when executed manually. What would be the problem? Help me with this please. (6 Replies)
Discussion started by: Santhosh CJ
6 Replies

3. Shell Programming and Scripting

[SOLVED] help clean up file movement script

Hello Group, Once again another script hacked together from a few sources to try and suit my needs. This is to go through a /temp directory and for each ls entry ask which Dir of three I want it sorted. The script works but there are a few behaviors that are odd so I figured I'd ask for help... (2 Replies)
Discussion started by: dpreviti
2 Replies

4. Shell Programming and Scripting

run unix script as scheduled job

Hi, I want my unix script to run as a scheduled job such that the script is invoked once every 15 minutes. Is there any way to achieve this other than running the script as a cron job? (2 Replies)
Discussion started by: vignesh53
2 Replies

5. Shell Programming and Scripting

sftp script file movement

Hi, I am newbie in unix scripting, I have written a bash script of SFTP that transfer some files from one folder to another within a server , I have two folders test and temp in the directory /home/p5060/sxk124 , the temp folder(/home/p5060/sxk124/temp)contain the files which I through my... (5 Replies)
Discussion started by: KAREENA18
5 Replies

6. Programming

Oracle Scheduled job not running as per schedule.

Hi, Though this is a unix forum mainly, am posting this oracle query here hoping to get a resolution. I have set up two scheduled jobs in oracle 11g for executiong a procedure in specific time intervals. One as Hourly and other as minutely. But the scheduled jobs are not running as per... (2 Replies)
Discussion started by: suresh_kb211
2 Replies

7. Shell Programming and Scripting

Running script file using cron job every 5 second

Hi All, I beginner in unix, i have no idea how to set the script file using cron job every 5 second. I also want to execute automatically the output to text file.This is my script name countsys.sh and my textfile abc.txt. (6 Replies)
Discussion started by: mastercar
6 Replies

8. UNIX for Dummies Questions & Answers

Scheduled job

I have a lot of jobs scheduled using at command. at -l gives only the job names and time ... how do i know which script is associated with which jobid. Thanks. (1 Reply)
Discussion started by: blackeyed
1 Replies

9. UNIX for Dummies Questions & Answers

problem when the script is scheduled to run as cron job

Hello, I have problem in executing a shell script. When the shell script is executed at the shell prompt the script works successfully but when the same script is run as a cron job it fails to execute the files called within the shell script. I have scheduled the job in my crontab file as ... (6 Replies)
Discussion started by: forumthreads
6 Replies

10. UNIX for Dummies Questions & Answers

AT job scheduled exactly 2 hours late

This occurs on an i386 box running Unix System V/386 Release 4.2 Ver 1.1.2. I have an 'at' scheduling anomaly whose behavior I am trying to understand. On one particular system, when an 'at' job is submitted, the time the job is actually scheduled to run is exactly 2 hours later than what the... (10 Replies)
Discussion started by: bohunk24
10 Replies
Login or Register to Ask a Question