What is your problem exactly? Does the option "--timeout 2m" not work? If that is the case, the manual says:
So try "--timeout 120" . And if you still do not trust it you might consider to use the "timeout" command:
Last edited by Ivo Breeden; 08-31-2018 at 07:12 AM..
Reason: formatting quote tags not as expected
This User Gave Thanks to Ivo Breeden For This Post:
I'm not 100% clear on what you might mean here, but I see two possibilities. A script will normally exit either when the last command it contains is executed, or when an exit statement is explicitly executed. So you don't really have to worry about "making sure it always ends" - by its very nature, a script will end so long as it contains no loop or logic that would cause it to keep running.
However, if what you're meaning here is that you want a command in your script to always exit after a certain amount of time to prevent it from running indefinitely, then you could try something like this:
Here you define command as the full command you want to run, and maxruntime as the maximum number of seconds it can be permitted to run for. The script then executes the command specified in the variable command in the background, with all output re-directed to /dev/null. It then waits for maxruntime seconds, and if the process still exists, it will attempt to kill it and show you the result.
Note that in its current form the script will always wait for maxruntime seconds no matter what, so even if your command has exited before then the script will wait at least that long. You could amend that easily enough though, but this is just to give you an idea of how this might work.
Hope this helps - if not, or if I've not quite grasped what you're actually struggling with here, then if you could provide a bit more info I'd be happy to help further.
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.?
------ 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:
So try "--timeout 120" . And if you still do not trust it you might consider to use the "timeout" command:
Yes, the command does work. I want to make sure nothing occurs whereby the stress commands does not end.
1. Use the full path in your command - so /usr/bin/stress (assuming that's where it's installed on your system, naturally) rather than just stress
2. Remove the double-quotes from around the "$command" statement, so that it simply reads $command
One modification you could make here would be to change the line defining maxruntime to this instead:
The variable $1 has a special meaning referring to the first command-line parameter passed into the script. So for a ten-second timeout, you could then run the script by typing script.sh 10, and when the script ran maxruntime would take the definition of the first parameter passed to the script - 10, in this case.
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)
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)
help
I am having text file like this...
------------------------END OF UPDATION ------------------
xxxxxxxxxxxxxxxxxxxxxxxxx
yyyyyyyyyyyyyyyyyyyyy
yyyyyyyyyyyyyyyyyyyyy
1 row updated
------------------------END OF UPDATION ------------------
TTTTTTTTTTTTTTTT
FFFFFFFFFFFFFFFFF
... (3 Replies)
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)