Repeat command

All those commands that we don't really use very often, but that we should ! Documented or not, they worth it !
Sam

Repeat command

Post 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:
cavagnaro

Re: Repeat command

Post by cavagnaro »

Uh? A cron job? That is more a linux issue

crontab -e
User avatar
frank
Alcatel Unleashed Certified Guru
Alcatel Unleashed Certified Guru
Posts: 3390
Joined: 06 Jul 2004 00:18
Location: New York
Contact:

Re: Repeat command

Post by frank »

if not, do a bash script.
man bash. google is your friend
Code Free Or Die
Eliott_DUP

Re: Repeat command

Post by Eliott_DUP »

while : ; do
command
sleep 5
done

:lol:

or
watch -n -d1
or
at
or
cfgCron
User avatar
finaluser
Member
Posts: 12
Joined: 09 Apr 2007 15:47
Location: Guatemala
Contact:

Re: Repeat command

Post 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
--
finaluser
User avatar
frank
Alcatel Unleashed Certified Guru
Alcatel Unleashed Certified Guru
Posts: 3390
Joined: 06 Jul 2004 00:18
Location: New York
Contact:

Re: Repeat command

Post 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 ..
Code Free Or Die
cavagnaro

Re: Repeat command

Post 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
ather-shahbaz

Re: Repeat command

Post 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
Eliott_DUP

Re: Repeat command

Post by Eliott_DUP »

do ?

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

Re: Repeat command

Post by cavagnaro »

Post Reply

Return to “Usefull commands”