Re: [bash] running script for specific time
- From: Enrique Perez-Terron <enrio@xxxxxxxxx>
- Date: Tue, 22 Apr 2008 20:26:12 GMT
On Tue, 22 Apr 2008 19:53:29 +0000, Jahoo wrote:
Hello
I would like to make script which:
will execute specific command (for example tcpdump, tail or something
like that - with some grep or cut pipes...) - it's of course easy BUT
i would like this command to be executed for specific time, for example
an hour and after that it should be stopped.
Can You help me one more time? :>
Not tested:
----8<--- cut here ---8<----
#!/bin/bash
timeout=$1
shift
("$@") &
sleep $timeout
kill -s TERM $!
----8<--- cut here ---8<----
Put the lines above in a file called do-for-seconds, make the file
executable, and run like this
$ ./do-for-seconds 3600 tcpdump -a -b -c otherargs
Regards
.
- References:
- [bash] running script for specific time
- From: Jahoo
- [bash] running script for specific time
- Prev by Date: A new reader? Welcome to comp.os.linux.misc, read this first if you're new here (FAQ)
- Next by Date: Re: Partitioning a back up drive--request for comments.
- Previous by thread: [bash] running script for specific time
- Next by thread: Re: [bash] running script for specific time
- Index(es):
Relevant Pages
|