Sponsored Content
Top Forums Shell Programming and Scripting Need help implementing a timout in my Shell Script for RHEL6 Post 302911159 by mo_VERTICASQL on Wednesday 30th of July 2014 12:46:39 PM
Old 07-30-2014
Ideally, I would like to implement less watcher scripts as a best practice (This is an enterprise environment)

and the script I am going to implement will run every minute so it might be an unnecessary load to do what you suggest.

If I am wrong or my assumptions in correct let me know.

and FYI, the script will be scheduled to run every 1 minute, in background.
It has a LOT of temporary variables too -so the cleanup process more complicated.

---------- Post updated at 12:03 PM ---------- Previous update was at 12:00 PM ----------

also I found this googling,

is this something that might work or no?


Code:
trap 'echo script_timeout ; exit ' USR1   
wait_n_sig() {    sleep $2    [ -d /proc/$1 ] && kill -s USR1 $1 }   
timeout() {    wait_n_sig $$ $1 & }   
timeout 5 read -p "Name: " name echo "Your name is " $name

---------- Post updated at 12:06 PM ---------- Previous update was at 12:03 PM ----------

DGPICKETT, for the watcher script you describe can you expand on the logic for me I am bit of an intermediate shell guy.

like I mean if its not too much could you expand:
1.....
2.....
3....

in terms of what you mean.

Thanks!

---------- Post updated at 12:14 PM ---------- Previous update was at 12:06 PM ----------

If I implement in my subshell the script running too long kill and email its just basically this right:
-----------------------------
(
##If runs for this time
##KILL MAIN.sh
##EMAIL NOTICE
)

MAIN.SH
------------------------------

---------- Post updated at 12:46 PM ---------- Previous update was at 12:14 PM ----------

Will this do as the watcher subshell ?


Code:
( sleep 20 ) & pid=$! ( sleep 2 && kill -HUP $pid ) 2>/dev/null & watcher=$! if wait $pid 2>/dev/null; then     echo "your_command finished"     pkill -HUP -P $watcher     wait $watcher else     echo "your_command interrupted" fi


Last edited by Franklin52; 07-30-2014 at 03:01 PM.. Reason: fixed tags
 

10 More Discussions You Might Find Interesting

1. IP Networking

tcp timout

I am led to understand that there when a port is bound for a tcp connection...once that connection is closed there is a timeout period before that port can be reused ... and the software I am using shows that. How long is this timeout - what affects it and is there anyway to reuce the timeout? (5 Replies)
Discussion started by: peter.herlihy
5 Replies

2. UNIX for Dummies Questions & Answers

Telnet timout question

ok here is a little bit on what I am trying to do. I am logged into a saolaris 9 server and telnet to another server to run an application that sits on the second unix / linux server. This application can sit idle for an hour to two and any given time. During this time the telnet session timesout... (4 Replies)
Discussion started by: Acleoma
4 Replies

3. Programming

Implementing a shell

I'm implementing a shell in C that supports piping, output redirection, and background processing, and a few other commands. I was wondering how I'd go about implementing the output redirection. So, I'd open a file and I'd fork and execute the command. But how would I get stdout into the file? Any... (10 Replies)
Discussion started by: ununium
10 Replies

4. Programming

need help in implementing simple interactive shell in C

hello all, i hv attached herewith my program to implement a simple interactive shell in C. no matter hw hard I try, I keep getting some errors. i need help - urgently !! proj1test7.c: In function `parseCommand': proj1test7.c:102: warning: assignment makes pointer from integer without a cast... (2 Replies)
Discussion started by: nix1209
2 Replies

5. Programming

Implementing a shell in C

Hi, I am implementing a shell in C, with the following problem... Suppose the shell is invoked from the command line as >> myshell < test.in > test.out 2>&1 I have to execute the commands in test.in and redirect them to test.out How does one detect in the main function that the shell... (1 Reply)
Discussion started by: jacques83
1 Replies

6. Homework & Coursework Questions

implementing mkdir, chdir, mv, pwd inside a shell !

1. The problem statement, all variables and given/known data: need to implement mkdir, chdir, mv, pwd given a shell.cpp directory.cpp and some other files this shell missing these commands, and i need to implement them inside the shell 2. Relevant commands, code, scripts,... (0 Replies)
Discussion started by: evantheking
0 Replies

7. Shell Programming and Scripting

Implementing Queue Using Shell scripts

HI I want to implement a control mechanism using Shell scripts .The intention is to have controlled number of jobs running in parallel External process will kickstart 40 jobs in parallel .All the 40 jobs will call the same generic script with different parameter values .But at a... (4 Replies)
Discussion started by: police
4 Replies

8. Shell Programming and Scripting

Help with implementing available memory status script

hi , i want write the script which automatically send an alert mail to my mail id when there is low memory available. things which i am able to implement -: i got the output of current memory status into one file . Than i break down the required coloumn and again send it in another file. My... (1 Reply)
Discussion started by: abhinav dixit
1 Replies

9. Shell Programming and Scripting

Implementing Listagg like function in shell

Hi, Basically what I am trying to do is making multiple fields of the same type comma-separated. i.e. for a data like this: B00000 abc B00001 abc,def B00001 ghi B00001 jkl B00002 abc B00002 def B00003 xyz Output should be like: B00000 abc B00001 abc,def,ghi,jkl... (20 Replies)
Discussion started by: prohank
20 Replies

10. Shell Programming and Scripting

Implementing linked list in shell scripting

Hello Experts, Is it possible to implement linked list in shell scripting? is yes then how can we do it? Any working example is highly appreciated. Thanks in advance. (4 Replies)
Discussion started by: mukulverma2408
4 Replies
SYSTEMD-TTY-ASK-PASSWORD-AGENT(1)			  systemd-tty-ask-password-agent			 SYSTEMD-TTY-ASK-PASSWORD-AGENT(1)

NAME
systemd-tty-ask-password-agent - List or process pending systemd password requests SYNOPSIS
systemd-tty-ask-password-agent [OPTIONS...] [VARIABLE=VALUE...] DESCRIPTION
systemd-tty-ask-password-agent is a password agent that handles password requests of the system, for example for hard disk encryption passwords or SSL certificate passwords that need to be queried at boot-time or during runtime. systemd-tty-ask-password-agent implements the Password Agents Specification[1], and is one of many possible response agents which answer to queries formulated with systemd-ask-password(1). OPTIONS
The following options are understood: --list Lists all currently pending system password requests. --query Process all currently pending system password requests by querying the user on the calling TTY. --watch Continuously process password requests. --wall Forward password requests to wall(1) instead of querying the user on the calling TTY. --plymouth Ask question with plymouth(8) instead of querying the user on the calling TTY. --console Ask question on /dev/console instead of querying the user on the calling TTY. -h, --help Print a short help text and exit. --version Print a short version string and exit. EXIT STATUS
On success, 0 is returned, a non-zero failure code otherwise. SEE ALSO
systemd(1), systemctl(1), systemd-ask-password-console.service(8), wall(1), plymouth(8) NOTES
1. Password Agents Specification https://www.freedesktop.org/wiki/Software/systemd/PasswordAgents systemd 237 SYSTEMD-TTY-ASK-PASSWORD-AGENT(1)
All times are GMT -4. The time now is 06:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy