Jump to content


Photo

some as cron but for 10-30s


  • Please log in to reply
8 replies to this topic

#1 ims

  • PLi® Core member
  • 13,625 posts

+212
Excellent

Posted 10 February 2016 - 15:24

Does exist some as cron, but for 10-30sec on box ? Cron is for t > 1minute. I want not create plugin, it is for e1.


Kdo nic nedělá, nic nezkazí!

Re: some as cron but for 10-30s #2 betacentauri

  • PLi® Core member
  • 7,185 posts

+323
Excellent

Posted 10 February 2016 - 17:08

Execute a script every minute and in the script do
execute
sleep 20 secs
execute
sleep 20 secs
execute
Xtrend ET-9200, ET-8000, ET-10000, OpenPliPC on Ubuntu 12.04

Re: some as cron but for 10-30s #3 ims

  • PLi® Core member
  • 13,625 posts

+212
Excellent

Posted 10 February 2016 - 17:19

With sleep ? Will not be some problem with it ?

 

Then could be some as ?:

while [ true ]; do
 sleep 20
 # here put what I want run
done


Kdo nic nedělá, nic nezkazí!

Re: some as cron but for 10-30s #4 MiLo

  • PLi® Core member
  • 14,045 posts

+298
Excellent

Posted 10 February 2016 - 17:30

Indeed. Just remove the "[", otherwise you'll get syntax errors.:

while true; do
 sleep 20
 # here put what I want run
done

Real musicians never die - they just decompose

Re: some as cron but for 10-30s #5 Erik Slagter

  • PLi® Core member
  • 46,960 posts

+541
Excellent

Posted 10 February 2016 - 18:41

Or use while [ 1 ] instead. Depends on whether [ and/or true is a shell builtin to select which to use ;)


* Wavefrontier T90 with 28E/23E/19E/13E via SCR switches 2 x 2 x 6 user bands
I don't read PM -> if you have something to ask or to report, do it in the forum so others can benefit. I don't take freelance jobs.
Ik lees geen PM -> als je iets te vragen of te melden hebt, doe het op het forum, zodat anderen er ook wat aan hebben.


Re: some as cron but for 10-30s #6 MiLo

  • PLi® Core member
  • 14,045 posts

+298
Excellent

Posted 10 February 2016 - 19:29

When "true" isn't built-in, I doubt that "test" will be...

The "[" is just an alias for "test".

AFAIK, even on busybox both are built-in.
Real musicians never die - they just decompose

Re: some as cron but for 10-30s #7 ims

  • PLi® Core member
  • 13,625 posts

+212
Excellent

Posted 11 February 2016 - 11:10

will not be problem with sleep (cca 20s) in loop there on E1 with single core ? Would not be better make it with sleep 1
 in some loop for delay ?

 

for a in 1 2 3 4 5 6 7 8 9 10 ...

do

   sleep 1

done


Kdo nic nedělá, nic nezkazí!

Re: some as cron but for 10-30s #8 Erik Slagter

  • PLi® Core member
  • 46,960 posts

+541
Excellent

Posted 11 February 2016 - 11:22

No don't do that. Make the sleep as long as possible. The sleep command maps 1:1 to a kernel call (probably pause()+alarm()) and the Linux kernel can deal very efficiently with processes in such "suspended" states. It just won't run for the specified amount of time. The only thing is that will have to be checked by the scheduler frequently, but the scheduler will have to do that for about 100 other processes and threads anyway, so it won't really matter.


* Wavefrontier T90 with 28E/23E/19E/13E via SCR switches 2 x 2 x 6 user bands
I don't read PM -> if you have something to ask or to report, do it in the forum so others can benefit. I don't take freelance jobs.
Ik lees geen PM -> als je iets te vragen of te melden hebt, doe het op het forum, zodat anderen er ook wat aan hebben.


Re: some as cron but for 10-30s #9 ozzsurf

  • Senior Member
  • 131 posts

+3
Neutral

Posted 16 February 2016 - 01:51

this works a treat

edit to suit

/usr/script/15sec.sh
 

#!/bin/bash
#This script run every 15 seconds

while (sleep 15 && touch abc.txt) &
do
wait $!
done



start the script  via softcam

/etc/init.d/softcam.15sec

 

#!/bin/sh

case "$1" in
start)
ulimit -s 512
exec start-stop-daemon -S -x /usr/script/15sec.sh &
;;
stop)
exec start-stop-daemon -K -R 2 -x /usr/script/15sec.sh &
sleep 2
killall -9 15sec.sh 2>/dev/null
sleep 2
rm -rf /tmp/15sec.sh
;;
restart|reload)
$0 stop
sleep 1
$0 start
;;
version)
echo "15sec"
;;
info)
echo "15sec.sh"
;;
*)
echo "Usage: $0 start|stop|restart"
exit 1
;;
esac
exit 0

 




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users