Running script in background continously |
Site Admin
|
Did you see jobs in the phpdock's ini?
They are run in background and therefore you may have something like this in a job handler: <? while (1) { do_my_great_work(); sleep(60 * 10); // 10 min to sleep } |
||||||||||||
_________________ The PHP IDE team |
|
Is there any built-in way of treating the jobs like actual CRON jobs (i.e. being able to schedule when the job runs, independent of when PHP Dock was launched)? For instance, I have an app that needs to perform an import. The data to import will be ready at a specific time each day, and I want a job to kick off at that time.
Based on your example here, the only way I can think of to accomplish this would be to calculate the amount of time until the import on startup and sleep that amount of time, perform the import, then subsequently sleep for 24 hours before performing the import again (in case the user leaves PHP Dock open all night, which is common). I'm pretty sure this would work, I was just wondering if there was a more elegant solution via the INI file for scheduling a job. Also, is there any way to get the settings in the phpdock.ini file from PHP code (maybe as server variables)? The reason I ask is that if I do have to schedule my jobs the way I described above, I would want to be able to specify the import time(s) in the INI file, as custom entries. Otherwise I suppose I could just open the INI file using PHP and read the entries directly, or put them in a separate INI file and read that. |
||||||||||||
|
Site Admin
|
I think that in one of the next versions we will change the way phpdock works with settings. It will be possible to embed ini and lic files into exe and distribute only exe. So it's not that good to update phpdock.ini by applications. Better to use your own ini file.
Almost correct, but you need to take into account that schedule may change while the thread is already sleeping. I think it's better not to sleep for longer than time granularity. If for example 10minutes precision is okay, split whole the amount of time into 10min chunks and make thread sleeping in the loop. Check for the timetable changes should be performed on each chunk (either before going sleep or right after).
fyi, there is a TimeSchedule thing in Windows: http://msdn2.microsoft.com/en-us/library/aa383614(VS.85).aspx all the API is available with command-line tool http://msdn2.microsoft.com/en-us/library/bb736357(VS.85).aspx |
||||||||||||||||
_________________ The PHP IDE team |
Running script in background continously |
|
||
Content © NuSphere Corp., PHP IDE team
Powered by phpBB © phpBB Group, Design by phpBBStyles.com | Styles Database.
Powered by
Powered by phpBB © phpBB Group, Design by phpBBStyles.com | Styles Database.
Powered by