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.
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)
help
I am having text file like this...
------------------------END OF UPDATION ------------------
xxxxxxxxxxxxxxxxxxxxxxxxx
yyyyyyyyyyyyyyyyyyyyy
yyyyyyyyyyyyyyyyyyyyy
1 row updated
------------------------END OF UPDATION ------------------
TTTTTTTTTTTTTTTT
FFFFFFFFFFFFFFFFF
... (3 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)
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)