Notice: Undefined offset: 0 in /var/www/html/qa-plugin/custom-override/pages/question.php on line 258

Notice: Trying to access array offset on value of type null in /var/www/html/qa-plugin/custom-override/pages/question.php on line 258
 How to make short pause in shell script? - Crowd Support Forum | Teltonika Networks

FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

14455 questions

17168 answers

28195 comments

0 members

We are migrating to our new platform at https://community.teltonika.lt. Moving forward, you can continue discussions on this new platform. This current platform will be temporarily maintained for reference purposes.
0 votes
162 views 0 comments
by
Hi

I'm running a shell script to catch changes in DIN1 pin and then executing some commands.

The catching of the changes need to be rather responsive so I would like to poll the pin about 10 times per second.

So I have a while loop with reading from the gpio.

In most shells I would use

   $ sleep 0.1

somewhere in the loop.  However it seem only to take integer seconds which is way too much.

I need some other mean of creating a pause that does not take all the resources.

If not, I will have to let it run at full speed. But that causes the load average go way above 1.0 which I do not like in the long run.

I can nice it and the load stays at 1.0. But then the responsiveness can be bad when other loads on the RUT are heavy.

So is there an alternative to "sleep" for making a delay?

best

Johan

Notice: Undefined index: title in /var/www/html/qa-theme/Teltonika/qa-theme.php on line 1490

Notice: Undefined index: title in /var/www/html/qa-theme/Teltonika/qa-theme.php on line 1490

Notice: Undefined index: title in /var/www/html/qa-theme/Teltonika/qa-theme.php on line 1490

Notice: Undefined index: title in /var/www/html/qa-theme/Teltonika/qa-theme.php on line 1604

Notice: Undefined index: title in /var/www/html/qa-theme/Teltonika/qa-theme.php on line 1605

1 Answer

0 votes
by anonymous
Install coreutils-sleep, you'll have the full-featured GNU sleep. From a ssh or CLI console;

opkg update

opkg install coreutils-sleep.

Regards,
Best answer

Notice: Undefined index: title in /var/www/html/qa-theme/Teltonika/qa-theme.php on line 1490

Notice: Undefined index: title in /var/www/html/qa-theme/Teltonika/qa-theme.php on line 1490

Notice: Undefined index: title in /var/www/html/qa-theme/Teltonika/qa-theme.php on line 1490

Notice: Undefined index: title in /var/www/html/qa-theme/Teltonika/qa-theme.php on line 1604

Notice: Undefined index: title in /var/www/html/qa-theme/Teltonika/qa-theme.php on line 1605