filetime and filedate in directory
filetime and filedate in directory
Hi,
I have some little problem, need updated filetime and filedate of some file in directory.
functions filetime() and filedate() return still some time and date when program running, but I need info about access time
when other users write to this file.
This looks to fact, that when program is running, still see directory without changes in real time.
Test program attached.
Note : I need some system to control external programs called with Runshell. I am working on system which do this :
main program call external program with runshell
when external program start , create temporary file to hdd and write to it some row for example date and time of start process
every x seconds also fopen and fclose this file to "tell" main program, that, external process still running
when process pass, this temporary file will delete or write some row for example stop at date and time
main program waiting to end of external program, and every x seconds test if temporary file exist, when no, this looks external process is ended, when exist also look to last access date and time, and when this is more than some limit, for example 30 seconds, this looks, that external process have some problem, frozen, or crashed.
But when I can not determine real access time, this not work.
Maybe I have some wrong in my test program, but this looks to not refreshing Directory() structure when XPP program running. When close and open, date and time load correct.
Thanks for all advices
I have some little problem, need updated filetime and filedate of some file in directory.
functions filetime() and filedate() return still some time and date when program running, but I need info about access time
when other users write to this file.
This looks to fact, that when program is running, still see directory without changes in real time.
Test program attached.
Note : I need some system to control external programs called with Runshell. I am working on system which do this :
main program call external program with runshell
when external program start , create temporary file to hdd and write to it some row for example date and time of start process
every x seconds also fopen and fclose this file to "tell" main program, that, external process still running
when process pass, this temporary file will delete or write some row for example stop at date and time
main program waiting to end of external program, and every x seconds test if temporary file exist, when no, this looks external process is ended, when exist also look to last access date and time, and when this is more than some limit, for example 30 seconds, this looks, that external process have some problem, frozen, or crashed.
But when I can not determine real access time, this not work.
Maybe I have some wrong in my test program, but this looks to not refreshing Directory() structure when XPP program running. When close and open, date and time load correct.
Thanks for all advices
- Attachments
-
- TestFiledateFiletime.zip
- (658.53 KiB) Downloaded 484 times
- Eugene Lutsenko
- Posts: 1649
- Joined: Sat Feb 04, 2012 2:23 am
- Location: Russia, Southern federal district, city of Krasnodar
- Contact:
Re: filetime and filedate in directory
Or maybe it's just when the process starts to create a file with the process ID, and when it ends to delete it?
Re: filetime and filedate in directory
Hi Eugene,
I do not understand what do you mean ?
I have one main program, and this run via Runshell several exe modules, which run on all CPU cores simultaneously.
With Runshell have not any feedback. Tasklist is not usable because process can be frozen, and for it i use "timestamp" rows in temporary file.
I do not understand what do you mean ?
I have one main program, and this run via Runshell several exe modules, which run on all CPU cores simultaneously.
With Runshell have not any feedback. Tasklist is not usable because process can be frozen, and for it i use "timestamp" rows in temporary file.
Re: filetime and filedate in directory
hi Victorio,
this Code is using Ot4Xb and give you Information if you App is still running
you also can "Terminate" running App what this Demo Source show
p.s. "switch" CPU before call TRunProcess() and Child App will run on that CPU even when MAIN "switch" again
Runshell does not give you a Handle and so your "Problem" beginmain program call external program with runshell
this Code is using Ot4Xb and give you Information if you App is still running
Code: Select all
#include "ot4xb.ch"
// ---------------------------------------------------------------------------
proc main()
local oProcess := TRunProcess():New()
local lActive := NIL
local dwExitCode
oProcess:cAppName := cPathCombine( GetWinDir(), "notepad.exe" )
// oProcess:cParams := cPathCombine( cAppPath(), "TRunProcess.prg" )
// oProcess:lInheritHandles := .T.
oProcess:wShowWindow := oProcess:swMinimize
oProcess:lUseShowWindow := .T.
// oProcess:lCreateNewConsole := .F.
// oProcess:Cmd( "DIR > test.txt" )
if oProcess:Start()
? "Running " , oProcess:cAppName
while oProcess:lTestActiveById()
// App is running
end
? "Exit Code: " , oProcess:GetExitCodeById()
greetings by OHR
Jimmy
Jimmy
Re: filetime and filedate in directory
Thank you Jimmy, i will look to it, this can be very usable for me.
I am using also other system to controlling runshell processes with DBF file, where this external processes write information about status , and main program read it , in database is fields CPU01 to CPU12 for example. Main program determine number of cores , and run this number external modules, when all fields in DBF have status "passed" complete process is passed.
Problem is , when some of external process crashed, or frozen, then main program wait and wait... .
I will look, how can use TRunprocess.
I am using also other system to controlling runshell processes with DBF file, where this external processes write information about status , and main program read it , in database is fields CPU01 to CPU12 for example. Main program determine number of cores , and run this number external modules, when all fields in DBF have status "passed" complete process is passed.
Problem is , when some of external process crashed, or frozen, then main program wait and wait... .
I will look, how can use TRunprocess.
Re: filetime and filedate in directory
Hi Victorio,
A solution can be to write the timestamp in the created files. If the file exists, you can check the content with a memoread. I suppose this is faster according to the directory() function.
In your main program, you can have an array which contains the time of your last check for each process. So you can check with the memoread for example each 5 seconds.
A solution can be to write the timestamp in the created files. If the file exists, you can check the content with a memoread. I suppose this is faster according to the directory() function.
In your main program, you can have an array which contains the time of your last check for each process. So you can check with the memoread for example each 5 seconds.
Re: filetime and filedate in directory
Chris,
Yes, I am writing to file time stamp
first when begin is text START date time
when processing, every x seconds for example every minute write text ACTIVITY date time
and when process passed, write STOP date time
then when some problem I can look or program can read from this files info about time how long processes works, also when missing STOP, this is info that process crashed or cancelled by user
Yes, I am writing to file time stamp
first when begin is text START date time
when processing, every x seconds for example every minute write text ACTIVITY date time
and when process passed, write STOP date time
then when some problem I can look or program can read from this files info about time how long processes works, also when missing STOP, this is info that process crashed or cancelled by user
Re: filetime and filedate in directory
Jimmy, please can you save attached file againg ? It cannot download, THX
Re: filetime and filedate in directory
Victorio,
So my suggestion is to read the content of the file to check if the process is still running instead of using the directory() function to check the time.
So my suggestion is to read the content of the file to check if the process is still running instead of using the directory() function to check the time.
Re: filetime and filedate in directory
Ok, Chris, i work on this variant.