aixtutorial
asked on
This is in AIX 5.3..I need a script that needs to run a command every 0.5 seconds
This is in AIX 6.1.and REHL 4.I need a script that needs to run a command every 0.5 secs..Please let me know as how this can be done
GNU sleep supports arbitrary floating point numbers (using a period before any fractional digits)
while true
do
<command>
sleep 0.5
done
As informed by omarfarid
> sleep will give you to wait minimum 1 sec then resume
You can use the following:
cat sleep_halfSec.c
Compile that code
Here goes the script which you need:
cat sleep_halfSec.sh
cat sleep_halfSec.sh
> sleep will give you to wait minimum 1 sec then resume
You can use the following:
cat sleep_halfSec.c
#include <unistd.h>
#include <time.h>
/* Sleep for milliseconds */
void sleepMilli(int millisec)
{
struct timespec tmsp;
tmsp.tv_sec = millisec / 1000;
tmsp.tv_nsec = (millisec % 1000) * 1000;
nanosleep(&tmsp, NULL);
}
int main()
{
sleepMilli( 500) ; /* which is 1000*0.5 */
return 0 ;
}
Compile that code
cc -g sleep_halfSec.c -o sleep_halfSec
Here goes the script which you need:
cat sleep_halfSec.sh
#!/bin/ksh
while true
do
echo Execute your required command
echo sleep for 0.5 second
sleep_halfSec
echo Execute your required command
done
orcat sleep_halfSec.sh
#!/bin/ksh
while [ 1 ]
do
echo Execute your required command
echo sleep for 0.5 second
sleep_halfSec
echo Execute your required commands
done
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
sleep will give you to wait minimum 1 sec then resume