Make cron wait for the child process


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Make cron wait for the child process
# 1  
Old 08-10-2010
Make cron wait for the child process

I am trying to find a list of files and writing it to a text file. Based on the machine performance the file writing will be slow at certain time.

The code to find file and redirecting the output to text file is on a shell script

Code:
/usr/bin/find  $SEARCH_DIR  -daystart \( \( -name 'KI*' -a -name '*.csv' \) -o  -name '*_xyz_*' \)  -mtime $DAYS_AGO -printf %f -printf "\n" | sort -r > File.txt

When the script is run manually thats fine. If I run in cron, how do I make it wait to finish the writing of file.txt ?
# 2  
Old 08-10-2010
why do you wait to write file.txt?
instead of may you mail to yourself with contenst of the file.txt
in next cron work time is refreshes file.txt (overwrite file.txt) and you look the new mail for new informations

Code:
 
/usr/bin/find  $SEARCH_DIR  -daystart ..... sort -r | mail -s "Find Results" root

# 3  
Old 08-10-2010
The problem is find is not writing all the files to files.txt. And the files.txt is needed for further processing.
# 4  
Old 08-11-2010
Quote:
Originally Posted by nuthalapati
The problem is find is not writing all the files to files.txt. And the files.txt is needed for further processing.
so files.txt is consisting and the find's result is half in txt only when the find works in cron?

what is the value of `$SEARCH_DIR` ?
# 5  
Old 08-11-2010
Maybe write to file_temp.txt and rename the file to the correct name when you have finished. Assuming that the next stage is in another cron that stage will need code to wait until the file is available.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Wait till any one child process finishes

Hi I am facing a problem in my ksh. My main script is calling 3 different child process in the background. I am using wait to finish all and then submit another 3 child processes. Now what i want is , whenever any one child process finishes ,i want to submit next one.so that parallel 3... (2 Replies)
Discussion started by: Sangu
2 Replies

2. Shell Programming and Scripting

How make parent to wait from child process?

Hi all, I am starting mgen5 for sometime depends on input from a file, in a child process. now I want to make parent to wait in this child process till mgen5 finishes, or timeout happens. could anyone please tell me how to make parent to wait in child process in shell script? thanks... (2 Replies)
Discussion started by: girijajoshi
2 Replies

3. UNIX for Dummies Questions & Answers

How to wait for a grand child to finish?

Hello all, I have a very basic question. I have a requirement where in, I have a main process which forks a child process, which execs and runs a c executable corresponding to a daemon. In the c executable corresponding to a daemon, as everyone does, I fork another child process, and as part of... (7 Replies)
Discussion started by: sai2krishna
7 Replies

4. Shell Programming and Scripting

forking a child process and kill its parent to show that child process has init() as its parent

Hi everyone i am very new to linux , working on bash shell. I am trying to solve the given problem 1. Create a process and then create children using fork 2. Check the Status of the application for successful running. 3. Kill all the process(threads) except parent and first child... (2 Replies)
Discussion started by: vizz_k
2 Replies

5. Programming

Parent,child wait,signal

Hello. I want to make a child do some stuff,wait,then the parent does some stuff and then child does some stuff and waits again.I have made the following but it does not work.Can anybody help me? pid1 = fork(); if (pid1 == -1) { perror("Can't create child\n"); ... (18 Replies)
Discussion started by: Cuervo
18 Replies

6. Programming

how can i make that a process child send a signal?

I'm trying to do a program that makes activate an signal (SINGALARM) when the next child of a son appears but this not works. I have to caught the next child o the other (pid), to send a singnal which inform a menssage. It's anything worng in the code? thanks. the code: #include... (2 Replies)
Discussion started by: marmaster
2 Replies

7. Shell Programming and Scripting

How to make the parent process to wait for the child process

Hi All, I have two ksh script. 1st script calls the 2nd script and the second script calls an 'C' program. I want 1st script to wait until the 'C' program completes. I cant able to get the process id for the 'C' program (child process) to make the 1st script to wait for the second... (7 Replies)
Discussion started by: sennidurai
7 Replies

8. UNIX for Advanced & Expert Users

how to make a parent wait on a child shells running in background?

Hi I have a shell script A which calls another 10 shell scripts which run in background. How do i make the parent script wait for the child scripts complete, or in other words, i must be able to do a grep of parent script to find out if the child scripts are still running. My Code: ... (1 Reply)
Discussion started by: albertashish
1 Replies

9. Shell Programming and Scripting

wait command - cat it wait for not-chile process?

Did not use 'wait' yet. How I understand by now the wait works only for child processes, started background. Is there any other way to watch completion of any, not related process (at least, a process, owned by the same user?) I need to start a background process, witch will be waiting... (2 Replies)
Discussion started by: alex_5161
2 Replies

10. Programming

Howto spawn multiple child processes and wait?

As far as I can tell, the bash wait command waits for a logical "AND" of all the child processes. Assuming I am coding in C: (1) What is the function I would use to create multiple bash child process running perl? (2) What is the function I would use to reinvent the bash wait command so I... (4 Replies)
Discussion started by: siegfried
4 Replies
Login or Register to Ask a Question