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
voliod(8)						      System Manager's Manual							 voliod(8)

NAME
voliod - Start, stop, and report on Logical Storage Manager kernel daemons SYNOPSIS
/sbin/voliod /sbin/voliod [-f] set count OPTIONS
The following option is used by voliod: Force the kill of the last I/O daemon. Without this option, the I/O daemons can only be reduced to one. DESCRIPTION
The voliod utility starts, stops, or reports on Logical Storage Manager I/O daemons. An I/O daemon is a process that provides a process context for processing any work that needs to be done to process Logical Storage Manager I/O. When invoked with no arguments, voliod prints the current number of volume I/O daemons on the standard output. When invoked with the set keyword, the number of daemons specified by count will be created. If more volume I/O daemons exist than are specified by count, then the excess processes will be terminated. If more than the maximum number are created (currently 64), the requested number will be silently truncated to that maximum. The number of daemons to create for general I/O handling depends on system load and usage. One daemon for each CPU on the system is gener- ally adequate, unless volume recovery seems unusually slow. Each I/O daemon starts in the background and creates an asynchronously-running kernel thread and becomes a volume I/O daemon. The voliod utility does not wait for these threads to complete. NOTES
LSM automatically sets the number of I/O daemons when the system starts, so it is usually not necessary to set or change the number of I/O daemons with this command. LSM I/O daemons cannot be killed directly through the use of signals. The number of Logical Storage Manager I/O daemons currently running can only be determined by running voliod; I/O daemons do not appear in the list of processes produced by the ps(1) command. EXIT CODES
The voliod utility prints a diagnostic on the standard error, and exits if an error is encountered. If an I/O error occurs within a spawned I/O daemon thread, then the I/O is not reflected in the exit status for voliod. Otherwise, voliod returns a nonzero exit status on errors. Usage errors result in an exit status of 1 and a usage message. If the requested number of daemons cannot be created, then the exit status is 2, and the number of daemons that were successfully started is reported. If any other error occurs, the exit status is 3. FILES
The device used to report on and start volume I/O daemon kernel threads. SEE ALSO
fork(2), volintro(8), vold(8), voldctl(8) ,pthread(8) voliod(8)
All times are GMT -4. The time now is 03:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy