PDA

View Full Version : autoexec not firing


ABC123

Lynda Huddleston
03-06-2005, 09:30 AM
I have created timed scripts to run at night.

script_schedule("Rebuild Indexes","11:24")
script_schedule("NOP Inv 1","11:25")
script_schedule("NOP Inv 2","11:29")
script_schedule("NOP Sales 1","11:31")
script_schedule("Rebuild Indexes","11:35")

I just put the times to current time so i could watch them fire and make sure they are right, but they aren't firing? I am in the control panel of a database that I built to always be open on the server. It only has the tables attached that are affected by the above scripts. What am I missing.

Thanks for your time,Lynda

Melvin Davidson
03-06-2005, 09:36 AM
Lynn,

From the Control Panel,
select View, Settings...

Check that
System, Prefernces, Autoexec Script, Execute the Autoexec Script ... value: YES

Lynda Huddleston
03-06-2005, 09:49 AM
I have check this and it was blank. So I put to YES, saved, closed and re-opened the db. Autoexec still did not execute. i have executed each script and operation that is scheduled to run and they all fire ok. Just can't get the autoexec to fire....

Melvin Davidson
03-06-2005, 10:01 AM
script_schedule() only replays a specific script, so you
should probably just include a
script_play("autoexec") as he first code line in all your
scheduled scripts.

Lynda Huddleston
03-06-2005, 11:07 AM
I'm not sure I understand. I want to fire several scripts throughout the night. That is why I have used the schedule() with a time. So that they each fire, one-at-a-time, with plenty of time inbetween so they don't collide. Can you not tell scripts within the autoexec when to fire? Or can I not have several in the autoexec? Sorry, I don't understand, but if you could suggest what you would do, I'd appreciate it...

Dan Blank
03-06-2005, 12:21 PM
Hi Lynda,

I tried your method for one script and it worked fine. I didn't try to get a second script to fire. Do you get one script to work at all?

The obvious thing that sticks out with me is the autoexec spelled correctly?

Just a thought.

Dan
Dan Blank Databases, Inc.

Melvin Davidson
03-06-2005, 12:25 PM
Lynn,

You stated the problem is that the autoexec script is not
executing. However, as you now describe it, that is not the
case. It is actually a matter of the scheduled scripts not
executing if you have the autoexec as follows:

'autoexec
script_schedule("Rebuild Indexes","11:24")
script_schedule("NOP Inv 1","11:25")
script_schedule("NOP Inv 2","11:29")
script_schedule("NOP Sales 1","11:31")
script_schedule("Rebuild Indexes","11:35")

==========================================
Is that correct?

I presume of course that you insure A5 stays running overnight.

However, the crux of the matter is in the documentation
for script_schedule:
To wit:
"There are ten timers available (1 - 10). If no parameter is specified timer 1 is used. There can only be one script assigned to each timer."

So perhaps if you amend the code to"

'autoexec
script_schedule("Rebuild Indexes","11:24", 1)
script_schedule("NOP Inv 1","11:25", 2)
script_schedule("NOP Inv 2","11:29", 3)
script_schedule("NOP Sales 1","11:31", 4)
script_schedule("Rebuild Indexes","11:35", 5)
==========================================

the problem should be solved.

If it still fails, after opening the database
try going to interactive and checking with
script1 = script_schedule_name_get(1)
script2 = script_schedule_name_get(2)
script3 = script_schedule_name_get(3)
script4 = script_schedule_name_get(4)
script5 = script_schedule_name_get(5)

Lynda Huddleston
03-06-2005, 01:55 PM
I knew it was something simple! THANKS....

One last question if you don't mind. I have built a DB for just the autoexec features that will stay open on the server. That way I can force it to open when the server reboots each night, and then run my scripts. I have not attached all tables to this DB, just the ones that are used in the scripts. However, I want the indexes to rebuild each night. If I don't attach all tables, will the "Rebuild Indexes" scripts only run on those attached? I'm assuming if I want all tables to reindex at night, I'll have to add all tables to the DB? Is this accurate?

THANK YOU AGAIN
Lynda

Melvin Davidson
03-06-2005, 02:17 PM
To answer your second (ie: "one more") question, it would
seem logical you would need to attach all tables in the
Rebuild_Indexes script, so there is no problem as to what
tables are refereneced.

Now some suggestions.
1. Make sure you force all users off Alpha Five to insure
there is no conflict. See

http://www.learnalpha.com/ShutDownNetwork/ShutDownNetwork.htm

I believe that answers another question of yours. :)

2. Make sure the second DB is also inthe same directory as as 1st (application) DB. That will make it easier to resolve table locations.

Happy to have helped,
Melvin

Lynda Huddleston
03-06-2005, 02:27 PM
Thank you for all the information and assistance

Stan Mathews
03-06-2005, 03:01 PM
Looks like Melvin got you fixed up with the scheduling. I might suggest a change to your logic. Why not schedule the first script

script_schedule("Rebuild Indexes","11:24")

Then have its last line (of "Rebuild Indexes") be

script_play("NOP Inv 1")

whose last line is

script_play("NOP Inv 2")

and so on.

Or make the last lines of "Rebuild Indexes" be

xbasic_wait_for_idle()
script_play("NOP Inv 1")
xbasic_wait_for_idle()
script_play("NOP Inv 2")
xbasic_wait_for_idle()
script_play("NOP Sales 1")
xbasic_wait_for_idle()
script_play("Rebuild Indexes")
end

Melvin Davidson
03-06-2005, 04:31 PM
Actually, you could enhance it even further to make it more
generic, and simpler.

Make a table call sheduled_scripts

FIELD Type Width Decimal
Script_order N 3 0
Script_name C 20

make an index "Script_order" = Script_Order
Then you could make a Batch_Script as follows:
====================================
'Batch_Script
dim num_scripts as N
dim curr_script as N

btbl = table.open("sheduled_scripts")
btbl.index_primary_put("Script_order")
num_scripts = btbl.records_get()
FOR curr_script = 1 to num_scripts
btbl.fetch(num_script)
xbasic_wait_for_idle()
script_play(btbl.Script_name)
curr_script = curr_script + 1
NEXT
====================================

Then you wouldn't have to modify the code if you
needed to add or delete a script, or change the order
all you need is

script_schedule("Batch_Script", "21:00", 1)

in the autoexec script :)