Page 1 of 2

Repeat command

Posted: 26 Jun 2007 17:36
by Sam
Hi,

Do you know the syntaxis to repeat a command for n times every minute? for an OXE?.

Thanks in advance for you comments.

Regards. :lol:

Re: Repeat command

Posted: 26 Jun 2007 20:18
by cavagnaro
Uh? A cron job? That is more a linux issue

crontab -e

Re: Repeat command

Posted: 28 Jun 2007 11:43
by frank
if not, do a bash script.
man bash. google is your friend

Re: Repeat command

Posted: 28 Jun 2007 18:04
by Eliott_DUP
while : ; do
command
sleep 5
done

:lol:

or
watch -n -d1
or
at
or
cfgCron

Re: Repeat command

Posted: 29 Jun 2007 20:05
by finaluser
I recommends to use crontab -e or edit /etc/crontab (as a root)

********* /etc/crontab ************
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
TERM=vt100 <<<<<<<<<<<<<<<<<<<<<<<<<<<< My Recomendation

# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
* * * * * mtcl /usr2/mtcl/getstats.sh <<<<<<<< Executable script file "chmod 755 getstats.sh"

*********** getstats.sh TrunkGroup or Board Address as paramaters ***
#!/bin/bash
### see free channels on TrunkGroup and write to file
## print Time
/bin/date +%X >> `date -I`.txt
/usr2/oneshot/mtcl/tool trkstat $1 $2 $3 | grep State | sed s/"|"//g | awk '{print $3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15}' | sed s/B//g | sed s/hs//g | grep F | sed s/" "//g | tr -d '\n' | wc -c` >> `date -I`.txt

### see busy channels on TrunkGroup and write to file
## print Time
/bin/date +%X >> `date -I`.txt
/usr2/oneshot/mtcl/tool trkstat $1 $2 $3 | grep State | sed s/"|"//g | awk '{print $3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15}' | sed s/F//g | sed s/hs//g | grep B | sed s/" "//g | tr -d '\n' | wc -c` >> `date -I`.txt

Re: Repeat command

Posted: 01 Jul 2007 00:47
by frank
Eliott / Finaluser

your script repeat things, but not N times like he wants.
Something like this would be better

for((i=0;$i<=100;i=$(($i+1))));do YOUR COMMAND HERE; done

this will repeat 100 times YOUR COMMAND. You can of course do a more complicated script in a bash file, depending on the time of the day, etc etc ..

Re: Repeat command

Posted: 01 Jul 2007 13:59
by cavagnaro
do{
command
}while(i>0)

there are so many ways to do loops. now, i'll begin to think on how will this may impact on oxe performance on the time

Re: Repeat command

Posted: 08 Oct 2009 10:03
by ather-shahbaz
for((i=0;$i<=100;i=$(($i+1))));do YOUR COMMAND HERE; done

this will repeat 100 times YOUR COMMAND. You can of course do a more complicated script in a bash file, depending on the time of the day, etc etc ..

Frank
I do above in this way

[root@xa011090 mtcl]# for((i=0;$i<=5;i=$(($i+1))));config 0; done
bash: syntax error near unexpected token `config'

Plz what may be reason for this error.

Ather

Re: Repeat command

Posted: 13 Oct 2009 13:57
by Eliott_DUP
do ?

for((i=0;$i<=5;i=$(($i+1))))do config 0;usleep 500000; done

Re: Repeat command

Posted: 13 Oct 2009 14:31
by cavagnaro