Running a program for a specified time
Hello again.
Does anyone know a way to force a program to run for a specified time and then shut down - some kind of script wizardry perhaps? The reason for this is that I'm connected to the 'net through an ADSL router, the port routes for which cause an unusual problem when I need net access. I have to repeatedly run lynx and shut it down (Ctrl-C) - for about 44 iterations. I can still ping my ISP's DNS', but anything beyond that seems to be unavailable until I do my little routine. Any help would be appreciated. |
you could run the program and then use either cron or at to "killall program name". Using at would be something like:
at 1:00pm killall program_name ctrl-d |
Well, I would rather think of cron, so you don't have to type it every time, the entry in crontab would look like:
Code:
20 2 * * * /usr/bin/run-parts /etc/cron.daily 1> /dev/null then you put your script that should run in /etc/cron.daily The script is two liner or more, but the first line should be #!/path/to/shell/or/interpreter like #!/bin/sh which invokes commands in Bourne Shell context. Code:
#!/bin/sh crontab -e |
programname & ; sleep 20m; killall programname
|
how about this
integer x=1 while ((x <=44)) do programname & sleep 10s killall programname ((x = x + 1)) fi |
All times are GMT -5. The time now is 12:59 PM. |