LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   There is Sleep, Watch Packages but not : run for X minutes, then stop :( (https://www.linuxquestions.org/questions/linux-general-1/there-is-sleep-watch-packages-but-not-run-for-x-minutes-then-stop-652230/)

frenchn00b 06-28-2008 09:01 AM

There is Sleep, Watch Packages but not : run for X minutes, then stop :(
 
There is Sleep, Watch Packages but not : run for X minutes, then stop :(

jomen 06-28-2008 09:38 AM

What do you want to do?

brianL 06-28-2008 11:09 AM

Think he wants to go jogging. :)

frenchn00b 06-28-2008 11:56 AM

Quote:

Originally Posted by brianL (Post 3197781)
Think he wants to go jogging. :)

indeed
http://www.humanflow.de/images/jogging_man.jpg
can linux train me to run longer distances ? :)


No, something like:
Code:

runfor 10m 'xclock & audacious & '
or not cute alternative
Code:

xterm  -e  'xclock & audacious & '  & sleep 10m ; killall -e xterm

Mr. C. 06-28-2008 12:10 PM

Code:

#!/bin/bash

SLEEPTIME=$1
shift
(( SLEEPTIME *= 60 ))

# Run command, saving pid
"$@" &
PID=$$

# nighty night
sleep $SLEEPTIME

# die !
kill $PID


frenchn00b 06-28-2008 12:18 PM

Code:

$ ./runfor 10s 'xlock ; audacious '
./runfor: line 5: ((: 10s: value too great for base (error token is "10s")
./runfor: line 8: xlock ; audacious : command not found


Code:

/usr/bin$ cat runfor
#!/bin/bash

SLEEPTIME=$1
shift
(( SLEEPTIME *= 60 ))

# Run command, saving pid
"$@" &
PID=$$

# nighty night
sleep $SLEEPTIME

# die !
kill $PID


Mr. C. 06-28-2008 12:29 PM

I left the unit conversion as an exercise for the reader. Current implementation, enter the number of minutes.

frenchn00b 06-28-2008 04:42 PM

Quote:

Originally Posted by Mr. C. (Post 3197837)
I left the unit conversion as an exercise for the reader. Current implementation, enter the number of minutes.

Would you think that doing :
Code:

runfor 60m "mplayer -vo null -vc dummy -dumpstream 'http://streaming.radionomy.com:8000/Retro-House-Belgium-' -dumpfile techno-radio-one-hour-only.mp3"
would work too?

Mr. C. 06-28-2008 07:19 PM

Try it for 1 minute.

runfor 1 ....

makuyl 06-29-2008 05:55 AM

apt-get install timeout
timeout 60 mplayer -vo null -vc dummy -dumpstream 'http://streaming.radionomy.com:8000/Retro-House-Belgium-' \
-dumpfile techno-radio-one-hour-only.mp3
should run it for one minute


All times are GMT -5. The time now is 01:43 AM.