Sponsored Content
Top Forums Shell Programming and Scripting Code that has to end no matter what Post 303022408 by drew77 on Friday 31st of August 2018 07:59:05 AM
Old 08-31-2018
Yes, I wanted to make sure the stress command does end.

If it didn't, it could burn up my CPU.

Thanks, I will study your code.

------ Post updated at 06:49 AM ------

stress is never executed.?

Code:
command="stress --cpu 8 --io 4 --vm 2 --vm-bytes 128M --timeout 1m"
maxruntime=60

"$command" >/dev/null 2>/dev/null &
watchpid=$!

/bin/sleep "$maxruntime"

if [ -d "/proc/$watchpid" ]
then
        echo "Max runtime exceeded, killing PID $watchpid"

        if /bin/kill -9 "$watchpid" >/dev/null 2>/dev/null
        then
                echo "Killed."
                exit 0
        else
                echo "Could not kill, please investigate manually."
                exit 1
        fi
fi

------ Post updated at 06:59 AM ------

Quote:
Originally Posted by Ivo Breeden
What is your problem exactly? Does the option "--timeout 2m" not work? If that is the case, the manual says:
Code:
-t, --timeout N
    timeout after N seconds

So try "--timeout 120" . And if you still do not trust it you might consider to use the "timeout" command:
Code:
$ timeout --help
Usage: timeout [OPTION] DURATION COMMAND [ARG]...
  or:  timeout [OPTION]
Start COMMAND, and kill it if still running after DURATION.

Yes, the command does work. I want to make sure nothing occurs whereby the stress commands does not end.
 

5 More Discussions You Might Find Interesting

1. Linux

Need help with this matter

I have a PC that was built in Europe pre-installed with Windows 2000. The HDD is 40GB, but, its split up as two 20GB (Taken up by Windows). I want to take over my Mandrake 9.1 CDs and install Linux on that machine. My question is, how would I proceed to install Linux this way??? Now, If... (1 Reply)
Discussion started by: wardialer
1 Replies

2. Shell Programming and Scripting

How to delete matter in between two lines

help I am having text file like this... ------------------------END OF UPDATION ------------------ xxxxxxxxxxxxxxxxxxxxxxxxx yyyyyyyyyyyyyyyyyyyyy yyyyyyyyyyyyyyyyyyyyy 1 row updated ------------------------END OF UPDATION ------------------ TTTTTTTTTTTTTTTT FFFFFFFFFFFFFFFFF ... (3 Replies)
Discussion started by: suryanarayana
3 Replies

3. Shell Programming and Scripting

Terminal to the front no matter what

Is there a way to bring the terminal script to the front? I am running this script through OMCEdit which is then running it through Terminal. I have some dialog boxes (using osascript) and the dialog boxes are not coming to the front...Terminal bounces and I have to click on Terminal to see the... (1 Reply)
Discussion started by: mainegate
1 Replies

4. Shell Programming and Scripting

grep matter between braces

#include<header.h> void classname :: pvvd_init ( abcd ,efgh ,ijkl ,mnop ) { rvcl_tabl_name_tabl.pvvd_init ( xxxx ,"tabl_mame" ) ; ... (2 Replies)
Discussion started by: ultimatix
2 Replies

5. UNIX for Dummies Questions & Answers

Strange system activity no matter what I try

When I choose to encrypt my drive during a Linux install, it encryps it, but I receive errors in dmesg and in ~/.xsessions-errors during use. The first error is in dmesg where it sometimes shows errors writing to the encypted device. The second error is in ~/.xsessions-errors with an error about... (0 Replies)
Discussion started by: justgoogleit
0 Replies
All times are GMT -4. The time now is 02:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy