Quantcast
Channel: How to start and kill the procedure? - Ask Ubuntu
Viewing all articles
Browse latest Browse all 5

Answer by Thomas for How to start and kill the procedure?

$
0
0

Use something like

#!/bin/bashjava -jar <name-of-the-jar-file> &javapid=$!sleep <some-time-in-seconds>kill $javapid

in a file, make it executable (chmod +x ) and run it using

./<filename>

This will start the jar-file and kill it after some time. There are several ways to excecute the command at regular intervals. You could use cron ( http://help.ubuntu.com/community/CronHowto ) to always excecut it as long the computer is runnig. Or use a simple shell script loop to start the execution from the command line:

#!/bin/bash COUNTER=0while [  $COUNTER -lt 100 ]; do<same as above without the first line>     let COUNTER=COUNTER+1 done

This will run the command 100 times, you could stop the execution simply by pressing ctrl-c.


Viewing all articles
Browse latest Browse all 5

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>