Sponsored Content
Top Forums Shell Programming and Scripting BASH - Handling background processes - distributed processing Post 302514591 by dcarrion87 on Sunday 17th of April 2011 02:07:03 AM
Old 04-17-2011
BASH - Handling background processes - distributed processing

NOTE: I am using BASH and Solaris 10 for this.

Currently in the process of building a script that has a main "watcher" daemon that reads a configuration file and starts background processes based on it's global configuration. It is basically an infinite loop of configuration reading. Some of the background processes do things like "decrypting files" and "encrypting files" all from a configuration table that is read in. Yes the sub processes have configuration files also. The idea is that the watcher process calls the sub process with an "ID" that is valid in the sub processes' configuration.

What I'm having trouble deciding on is how to deal with things like notifications via email on how the sub process finished. They run in the background from the watcher process so assuming after it's finished I can't tell the watcher what happened. These sub processes can be called without the watcher as well. E.g.

Code:
# ClientDataDecrypt 1

Where 1 is the ID from a table configuration.

My thoughts were to:
1. Have the watcher touch a stat file when it kicks off the particular subtask. The sub process can then update this. I can also use this to stop the watcher from kicking off another sub process too quickly.
2. Have the watcher pass the relevant email addresses to the sub process and let the sub process handle the notifications. There still may be an issue with spam notifications if the sub process fails on particular files.

Sorry if I have confused what I'm trying to do. Your thoughts and feedback are welcome.

---------- Post updated at 04:07 PM ---------- Previous update was at 02:42 PM ----------

Thinking further about this I'm thinking that when I kick off the sub process I have it spit to an output file:

Code:
# ClientDataEncrypt -i <id> -o <path>_<id>_<parent>.lock

Where ID is the ID in the config, <path> is the parent file path, and <parent> is the parent (watcher) process ID.

I can then from the watcher keep checking for files matching the above criteria as it parses through. The out file can have something like this to read in:

SUCCESS=
FAIL=
SOURCE_DIR=
DEST_DIR=

It can then construct a notification based on this.
 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Background processes

How do you capture the return code from a background process? I am dumping data to a fifo and then processing it in a c program. I need to know that the sql finished successfully to ensure no missing data. Thanks. ex. sqlplus user/password < get_data.sql > data_fifo.txt & bin/process_data... (2 Replies)
Discussion started by: korndog
2 Replies

2. Shell Programming and Scripting

Handling Stdout&StdErr for background jobs.

Hello Friends, sorry, i am not very familiar with Unix programming. Could you please help me on this? We have to start different components from a startup script. each components are started as below in the background in a startprocess function $nohup $file $args >>$logFile 2>&1 & ... (0 Replies)
Discussion started by: alvinbush
0 Replies

3. Solaris

Handling Stdout&StdErr for background jobs.

Hello Friends, sorry, i am not very familiar with Unix programming. Could you please help me on this? We have to start different components from a startup script. each components are started as below in the background in a startprocess function $nohup $file $args >>$logFile 2>&1 & ... (1 Reply)
Discussion started by: alvinbush
1 Replies

4. Linux

background processing in BASH

I have script 3 scripts 1 parent 2 children child1 child2 In the code below the 2 child processes fire almost Instantaneously in the background, Is that possible to know the status of pass/fail of each process "as it happens" ? In the present scenario although Child2... (5 Replies)
Discussion started by: jville
5 Replies

5. Shell Programming and Scripting

background processing in BASH

I have script 3 scripts 1 parent (p1) and 2 children child1 and child2 I have script 3 scripts 1 parent 2 children child1 child2 In the code below the 2 child processes fire almost Instantaneously in the background, Is that possible to know the status of pass/fail of each process... (12 Replies)
Discussion started by: jville
12 Replies

6. Shell Programming and Scripting

Background Processes

Ok guys so I have my first dummy shell almost done except for one tiny part: I do not know how to run a process in the background, from the code! I already know how to do that in a normal shell: $ program & However, no clue when it comes to how to program that thing. :eek: A very... (2 Replies)
Discussion started by: Across
2 Replies

7. Shell Programming and Scripting

Need help on background processes

Hi, I have a schell script parent.ksh from which I am calling three background processes a.ksh,b.ksh and c.ksh. Once these three processes completes the next step in parent.ksh should execute. How to achieve this? Please help me.... Thanks... (1 Reply)
Discussion started by: ravinunna
1 Replies

8. UNIX for Advanced & Expert Users

File Processing: Handling spaces in a line

Hi All, Iam trying to get a file processed and some lines have spaces...the below is not working Want to remove empty line Want to remove lines that start with # Avoid line with substring WHOA When trying to get the substring from the var also Iam having trouble file is like VAR=VALUE,... (13 Replies)
Discussion started by: baanprog
13 Replies

9. Shell Programming and Scripting

Help with shell script handling processes

Hello I have a file which has around 120 lines of commands. I am trying to write a shell script like which reads the 'command' file and executes line by line with some additional (common argument) with maximum 6 commands active at a time. Each of these commands when executed takes time... (5 Replies)
Discussion started by: JackyShane_36
5 Replies
KILLALL5(8)						Linux System Administrator's Manual					       KILLALL5(8)

NAME
killall5 -- send a signal to all processes. SYNOPSIS
killall5 -signalnumber [-o omitpid[,omitpid..]] [-o omitpid[,omitpid..]..] DESCRIPTION
killall5 is the SystemV killall command. It sends a signal to all processes except kernel threads and the processes in its own session, so it won't kill the shell that is running the script it was called from. Its primary (only) use is in the rc scripts found in the /etc/init.d directory. OPTIONS
-o omitpid Tells killall5 to omit processes with that process id. NOTES
killall5 can also be invoked as pidof, which is simply a (symbolic) link to the killall5 program. EXIT STATUS
The program return zero if it killed processes. It return 2 if no process were killed, and 1 if it was unable to find any processes (/proc/ is missing). SEE ALSO
halt(8), reboot(8), pidof(8) AUTHOR
Miquel van Smoorenburg, miquels@cistron.nl 04 Nov 2003 KILLALL5(8)
All times are GMT -4. The time now is 09:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy