Forum Moderators: coopster
time span 12:50:00 to 13:05:00
$start_time = 12:50:00;
$stop_time = 13:05:00;
$interval = 60;
$repeater = 2;
table ‘tasks’
id ¦ time ¦ code ¦ action ¦ status ¦ created ¦ lock
---------------------------------------------------------------------------------
3 ¦ 12:52:00 ¦ 303 ¦ action3.php ¦ idle ¦ 2004-01-17 12:45:00 ¦ false
2 ¦ 12:51:00 ¦ 202 ¦ action2.php ¦ idle ¦ 2004-01-17 12:45:00 ¦ false
1 ¦ 12:50:00 ¦ 303 ¦ action3.php ¦ done ¦ 2004-01-17 12:45:00 ¦ true
tasks
‘id=1’ $starttime (12:50:00)
‘id=2’ $starttime + $interval (60 seconds)
‘id=3’ last time (12:51:00) + $interval (60 seconds)
Keywords: cron, crontab, exec()
Server: Apache, PHP, MySQL
MySQL tables
table ‘engine’
engineID ¦ status
- - - - - - - - - -
1 ¦ ON
next_start, processing_time and interval unit of time is second.
table ‘start_engine’
startID ¦ next_start ¦ processing_time
- - - - - - - - - - - - - - - - - - - - - - -
1 ¦ 60 ¦ 60
2 ¦ 300 ¦ 900
3 ¦ 1800 ¦ 900
‘actions’ is interval repeater
table 'processes'
processID ¦ interval ¦ actions
- - - - - - - - - - - - - - -
1 ¦ 60 ¦ 1
2 ¦ 60 ¦ 2
3 ¦ 1 ¦ 3
4 ¦ 5 ¦ 2
table ‘codes’
codeID ¦ code ¦ command
------------------
1 ¦ 101 ¦ action1.php
2 ¦ 202 ¦ action2.php
3 ¦ 303 ¦ action3.php
example:
if engine ‘ON’ then time now() + random(startID) + random(processID) + random(codeID)
time now is 12:49:00 + 60 sec = 12:50:00
next_start = 12:50:00
How to create dynamically generated table
time span 12:50:00 to 13:05:00
$start_time = 12:50:00;
$stop_time = 13:05:00;
$interval = 60;
$repeater = 2;
table ‘tasks’
id ¦ time ¦ code ¦ action ¦ status ¦ created ¦ lock
---------------------------------------------------------------------------------
3 ¦ 12:52:00 ¦ 303 ¦ action3.php ¦ idle ¦ 2004-01-17 12:45:00 ¦ false
2 ¦ 12:51:00 ¦ 202 ¦ action2.php ¦ idle ¦ 2004-01-17 12:45:00 ¦ false
1 ¦ 12:50:00 ¦ 303 ¦ action3.php ¦ done ¦ 2004-01-17 12:45:00 ¦ true
tasks
‘id=1’ $starttime (12:50:00)
‘id=2’ $starttime + $interval (60 seconds)
‘id=3’ last time (12:51:00) + $interval (60 seconds)
time now() + random(startID) + random(processID) + random(codeID) and output = table ‘display’
table ‘timer’
timerID ¦ start ¦ end
- - - - - - - - - - - - - - -
1 ¦ 12:50:00 ¦ 13:05:00
table ‘tasks’
table ‘display’
id ¦ time ¦ codeID ¦ command
-------------------------------------
1 ¦ 12:50:00 ¦ 303 ¦ action3.php
2 ¦ 12:50:05 ¦ 101 ¦ action1.php
3 ¦ 12:50:10 ¦ 303 ¦ action3.php