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
AnyEvent::AggressiveIdle(3pm)				User Contributed Perl Documentation			     AnyEvent::AggressiveIdle(3pm)

NAME
AnyEvent::AggressiveIdle - Aggressive idle processes for AnyEvent. SYNOPSIS
use AnyEvent::AggressiveIdle qw(aggressive_idle}; aggressive_idle { ... do something important }; my $idle; $idle = aggressive_idle { ... do something important if (FINISH) { undef $idle; # do not call the sub anymore } }; DESCRIPTION
Sometimes You need to do something that takes much time but can be split into elementary phases. If You use AE::idle and Your program is a highload project, idle process can be delayed for much time (second, hour, day, etc). aggressive_idle will be called for each AnyEvent loop cycle. So You can be sure that Your idle process will continue. EXPORTS
aggressive_idle Register Your function as aggressive idle watcher. If it is called in VOID context, the watcher wont be deinstalled. Be carrefully. In NON_VOID context the function returns a guard. Hold the guard until You want to cancel idle process. stop_aggressive_idle You can use the function to stop idle process. The function receives idle process PID that can be received in idle callback (the first argument). Example: use AnyEvent::AggressiveIdle ':all'; # or: use AnyEvent::AggressiveIdle qw(aggressive_idle stop_aggressive_idle); aggressive_idle { my ($pid) = @_; .... stop_aggressive_idle $pid; } The function will throw an exception if invalid PID is received. Continuous process. Sometimes You need to to something continuous inside idle callback. If You want to stop idle calls until You have done Your work, You can hold guard inside Your process: aggressive_idle { my ($pid, $guard) = @_; my $timer; $timer = AE::timer 0.5, 0 => sub { undef $timer; undef $guard; # POINT 1 } } Until 'POINT 1' aggressive_idle won't call its callback. Feel free to stop_aggressive_idle before free the guard. AUTHOR
Dmitry E. Oboukhov, <unera@debian.org> COPYRIGHT AND LICENSE
Copyright (C) 2011 by Dmitry E. Oboukhov This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available. VCS
The project is placed on my GIT repo: <http://git.uvw.ru/?p=anyevent-aggressiveidle;a=summary> perl v5.10.1 2011-03-01 AnyEvent::AggressiveIdle(3pm)
All times are GMT -4. The time now is 04:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy