Help with Shell Script automation


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with Shell Script automation
# 1  
Old 12-21-2009
Help with Shell Script automation

can someone look into this one please... I am struck at this point. I do not know what logic to be followed here. I can go ahead with my work only, if this step is done. Please Help.

I have a process X in a shell script. Once the process X is done, it generates a log file. Process X is basically a java application. We cannot assume how much time would be required for the process X to be completed once it is kicked off..

The shell script looks something like this:

Code:
date_current=`date +%m%d%y`

java -Xms512m -Xmx512m com.mainloader.databaseLoader S 12 F > file.log.$date1

I should write a shell script "Y" in such a manner, that my shell script "Y" should be able to
1. check as and when the log file from the process X is created.
2. once the log file is created, my script "Y" should be able to move the created log file to a different directory.

that is my script Y should automatically move the newly created log files to a different directory, immediately after the log file is created. I am not able to understand the logic here.
# 2  
Old 12-21-2009
The safest thing to do is change process X, do not create a process Y.

Code:
date_current=`date +%m%d%y`
java -Xms512m -Xmx512m com.mainloader.databaseLoader S 12 F > file.log.$date1 fname="file.log.$date1"
mv $fname /path/to/new/${fname}

Otherwise you are stuck with a kludge-y kind of thing where you call lsof or fuser repeatedly until you see that the logfile is no long open. See the man page on your system

example:
Code:
lsof /path/to/file.log.$date1
while [[ $? -ne 0 ]]
do
       sleep 10
       lsof /path/to/file.log.$date1
done

This does a lot of pointless polling. If your system has inotify (Linux/GNU derivative) you can call inotify to see when a file is closed. Same polling problem though.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script automation using cron which query's MySQL Tables

What I have: I have a input.sh (script which basically connect to mysql-db and query's multiple tables to write back the output to output1.out file in a directory) note: I need to pass an integer (unique_id = anything b/w 1- 1000) next to the script everytime I run the script which generates... (3 Replies)
Discussion started by: kkpand
3 Replies

2. Shell Programming and Scripting

Automation Script for Oracle

Hi, As a Oracle Developer, I am writing many Procedures,Functions and Packages. Facing Many optimization issue after writing these Database objects. Trying to tune it manually. Can we write any Shell/Perl/Python script to Optimize these Database objects instead of doing manual check and... (1 Reply)
Discussion started by: vasuvv
1 Replies

3. Shell Programming and Scripting

Automation script

Hello All , I came across a tricky solution to devolop . Here is a part of the requirement automation . I have different set of server say : Web ( has 4 servers under it ) , App ( has 4 servers under it ) , DB ( has 2 servers under it ) Above each i have different load balancers , Say : Web... (4 Replies)
Discussion started by: radha254
4 Replies

4. Shell Programming and Scripting

Script Automation

Hi Gurus, I have a clearcase script that i use to check in a single file at time on my clearcase server. the script is as follows setmyview settask 75098_MSI_TRILOGY_EIM cd /vobs/Trilogy_R12/custom/msieim/12.0.0/sql/ cleartool co -nc . ct mkelem -nc Filename_1.sql cp... (3 Replies)
Discussion started by: r_t_1601
3 Replies

5. Shell Programming and Scripting

shell script help needed to manage FTP automation

Hi, I am very new in shell scripting. Have managed to prepare a script which will work to download data to local directory. But facing below problem. :wall: Please help me out. Thanks in advance. Problem: 1. I am unable to use delete command to delete data in the ftp location (I have... (2 Replies)
Discussion started by: ImranBD
2 Replies

6. Shell Programming and Scripting

Help with Truststore automation shell script

Please close this thread. I have raise this question in appropriate thread. Thanks (0 Replies)
Discussion started by: KuldeepSinghTCS
0 Replies

7. Shell Programming and Scripting

Automation shell scripting

Hi All, Consider my script is getting input from user under utc/stb path. I should automate the script by reading inputs from .txt file. Whenever script is prompting for input, it should read from input file. Now, i have to create a script in different path that should run my old script by... (4 Replies)
Discussion started by: poons
4 Replies

8. Shell Programming and Scripting

korn shell automation problem!

I got the task writting Korn Shell script to automate the tuxedo login so that users neednot have to enter options manually. I have done that using expect tool from the Unix but my manger told me its not secure so you have to do that using Kornshell without using Expect. Here is the way to login to... (0 Replies)
Discussion started by: pareshan
0 Replies

9. Shell Programming and Scripting

FTP automation script

Hi, I have got a requirement like this. a parameterized function custFtp which will take 5 i/ps and will do the following tasks. p1) server name p2) username p3) password p4) path name of the server where the file resides p5) file name pattern the function will work like this. ... (1 Reply)
Discussion started by: ani_datta
1 Replies

10. Shell Programming and Scripting

Shell script automation using case statement

Hi, I'm trying to write a shell script that has a menu and then dependant on the selection, will automate some samba file transfer. The problem is when I run the code without the case statement it runs fine. but when I put the case statement in the only way I can get the code to run is to... (6 Replies)
Discussion started by: ianf
6 Replies
Login or Register to Ask a Question