Register
It is currently Fri Nov 28, 2014 6:11 am

dur - run command for a specific duration


All times are UTC - 6 hours


Post new topic Reply to topic  [ 1 post ] 
Author Message
 PostPosted: Tue Apr 06, 2010 3:58 pm   

Joined: Wed Mar 10, 2010 8:05 pm
Posts: 25
swiped this method from somewhere on the net and made some adjustments

Code:
#!/bin/bash

#usage: dur [seconds] [command]
#usage: dur [seconds] ["command -arg"]

runtime=${1:-1m}
mypid=$$
shift
$@ &
cpid=$!
sleep $runtime
kill -s SIGTERM $cpid


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP