possible to begin a task at a specific SECOND?

nnCron and nnCron LITE discussion

possible to begin a task at a specific SECOND?

Postby LuckMan212 » Wed, 06 Jul 2005, 10:25

hello,

I would like to know, it is possible to define that a Task should begin at a specific SECOND. Like 09:29:57 (hh:mm:ss) ?

I have "worked around" this apparent limitation by doing the following:
Code: Select all
#( opening_bell
\ play a sound at 9:29:57
Time: 29 9 * * 1-5 *
Action:
PAUSE: 57000
PLAY-SOUND: "C:\WINDOWS\Media\openingbell.wav"
)#


is this the only way or is there a more elegant/correct way to do this??
thanks
LuckMan212
 
Posts: 133
Joined: Mon, 04 Jul 2005, 11:19

Postby VK » Wed, 06 Jul 2005, 11:53

The seconds counting is not really accurate in PC-world and heavy depends on your hardware and CPU usage.

So, you post a good example of starting a task in exact second. If you need to start a task say every count of seconds you can use an endless loop. You can find an example of this technique in nnCron FAQ.
CU
VK
User avatar
VK
 
Posts: 680
Joined: Wed, 14 Jul 2004, 19:17

Postby LuckMan212 » Wed, 06 Jul 2005, 14:23

ok Thank you for reassuring me.
although I am surprised to hear that PC hardware is unable to accurately execute in a 1-second timeframe, especially considering that the PAUSE function is measured in milliseconds.

But, this works and so I will not worry about it anymore :)
LuckMan212
 
Posts: 133
Joined: Mon, 04 Jul 2005, 11:19

Postby VK » Wed, 06 Jul 2005, 14:40

Just imagine you are counting seconds when you are starting Photoshop or some other heavy app... Your PC can just freeze for a couple of seconds - this is how the 'preemptive multitasking' works...
CU
VK
User avatar
VK
 
Posts: 680
Joined: Wed, 14 Jul 2004, 19:17

Postby mantra » Sat, 11 Feb 2006, 21:42

um
can i do a loop of for example 30 seconds , every 30 seconds for example do a job, or run a job evey 90 seconds

i would like to know how can i job , i search in the guide but :oops:
mantra
 
Posts: 65
Joined: Tue, 08 Mar 2005, 18:48

Postby LuckMan212 » Sat, 11 Feb 2006, 22:11

i can only think of 1 way, maybe Valery or Nicholas will have a better way. These pair of tasks should work together so that useful_task runs every 30 seconds......... also If I remember correctly from the documentation, the "caller" task must come AFTER the "callee" task.

Code: Select all
#( useful_task
NoActive
Action:
   \ something useful...........
)#

#( useful_task_helper
Time: * * * * * *
Action:
   useful_task RUN
   PAUSE: 30000
   useful_task RUN
)#


And in fact I believe that you can even omit the "Time: * * * * * *" section, and I think it will still work.

Edit: I missed the part above where you asked about running a task every 90 seconds. That is a little more difficult, at lesat for me. You might try something like this:

Code: Select all
#( useful_task
NoActive
Action:
   \ something useful...........
)#

#( useful_task_helper
SingleInstance
RunOnce
NoDel
Action:
   BEGIN
      useful_task RUN
      PAUSE: 90000
   AGAIN
)#
I didnt test this, I am not sure if it will work...
Last edited by LuckMan212 on Sat, 11 Feb 2006, 22:35, edited 1 time in total.
LuckMan212
 
Posts: 133
Joined: Mon, 04 Jul 2005, 11:19

Postby mantra » Sat, 11 Feb 2006, 22:28

:shock:
in the guide there is not a example
but in the faq.txt

is there
Code: Select all
#( test_10sec
    Action:
    \ defining the loop:
    \ 6 iterations with 10 seconds pause between each iteration
    6 0 DO
            START-APP: your_app.exe
            PAUSE: 10000
        LOOP
    )#
mantra
 
Posts: 65
Joined: Tue, 08 Mar 2005, 18:48

Postby mantra » Sat, 11 Feb 2006, 22:31

LuckMan212 thanks for the answer

are u able to run a job every x days?
for example every 3 days .. :?
mantra
 
Posts: 65
Joined: Tue, 08 Mar 2005, 18:48

Postby LuckMan212 » Sat, 11 Feb 2006, 22:39

ok, I think that is easy:

Code: Select all
#( task_to_run_every_3days
\ this will run every 3 days at 6pm
Time: 0 18 */3 * * *
Action:
   \ something useful...........
)#

Also, I updated my other post (look up) and added a sample code to run a task every 90 seconds. I didnt test it but it looks like it should work.
LuckMan212
 
Posts: 133
Joined: Mon, 04 Jul 2005, 11:19

Postby mantra » Sat, 11 Feb 2006, 22:40

thanks luckyman

about your task every days i get errors
mantra
 
Posts: 65
Joined: Tue, 08 Mar 2005, 18:48

Postby LuckMan212 » Sat, 11 Feb 2006, 23:21

hmm.. ok well maybe try smth like this:

Code: Select all
#( task_to_run_every_3days
\ this will run every 3 days at 6pm
Time: 0 18 * * * *
Action:
FILE-EXIST: "3days.sem" 0=
IF
    FILE-CREATE: "3days.sem"
ELSE
    CUR-DATE
    FILE-CREATION-DATE: "3days.sem"
    DATE- 2 >
    IF
       \ ... do your important stuff here ...
       FILE-DELETE: "3days.sem"
       FILE-CREATE: "3days.sem"
    THEN
THEN
)#

again I havent tested it, but it should work,,,,,,,, :roll:
LuckMan212
 
Posts: 133
Joined: Mon, 04 Jul 2005, 11:19

Postby LuckMan212 » Tue, 14 Feb 2006, 10:51

so mantra does that work?
LuckMan212
 
Posts: 133
Joined: Mon, 04 Jul 2005, 11:19

Postby mantra » Wed, 15 Feb 2006, 15:15

tested works :lol: :D
thanks
mantra
 
Posts: 65
Joined: Tue, 08 Mar 2005, 18:48

Postby Naanamari » Sun, 23 Jul 2006, 09:01

yes, i think so... :)
Naanamari
 
Posts: 1
Joined: Sun, 23 Jul 2006, 09:01

Re: possible to begin a task at a specific SECOND?

Postby ahatchkins » Mon, 04 Jan 2010, 15:58

#( useful_task
NoActive
Action:
\ something useful...........
)#

#( useful_task_helper
Time: * * * * * *
Action:
useful_task RUN
PAUSE: 30000
useful_task RUN
)#

If useful_task takes a couple of seconds to finish using RUN would be incorrect. The task wont be run exactly 'every 30 seconds'.

LAUNCH starts the task in a separate thread and moves to next instruction immediately. It will be closer to 'every 30 seconds' condition.
ahatchkins
 
Posts: 2
Joined: Fri, 25 Dec 2009, 00:18

Next

Return to nnCron forum (English)

Who is online

Users browsing this forum: No registered users and 3 guests

cron