Page 2 of 2

Re: filetime and filedate in directory

Posted: Wed Aug 10, 2022 6:19 am
by Wolfgang Ciriack
You can open a file in your process and let it open.
If you cannot delete this file from another process, the process is still running.
When the file creating process has finished, it closes and delete the file. When the process crashes, you can delete the file, too.
I do this f.e. with login-files for every user.

Re: filetime and filedate in directory

Posted: Wed Aug 10, 2022 9:44 pm
by Eugene Lutsenko
Wolfgang Ciriack wrote: Wed Aug 10, 2022 6:19 am You can open a file in your process and let it open.
If you cannot delete this file from another process, the process is still running.
When the file creating process has finished, it closes and delete the file. When the process crashes, you can delete the file, too.
I do this f.e. with login-files for every user.
Something like this is what I meant

Re: filetime and filedate in directory

Posted: Thu Aug 11, 2022 12:03 am
by Auge_Ohr
hi Victorio,
Victorio wrote: Wed Aug 10, 2022 3:40 am please can you save attached file againg ? It cannot download, THX
it will not help in this Forum.
as you can see there are People who have download Sample but other User get "file not found" ...

write me a private Message with your Email Adress so i can send Sample to you

Re: filetime and filedate in directory

Posted: Thu Aug 11, 2022 6:46 am
by Victorio
Wolfgang and Eugene:

I am testing it, but I am also dealing with the situation, when external process still run, but stay in cycle, or "frozen" .
In this situation read every x seconds last row from temporary "TIM" file and when actually time - last time from "TIM" file is more than for example 30 seconds, this is signal,
that external process not work.

Here is example temporary TIM file where external program write row every 1 second :
START na CPU : 2 - 20220810 14:59:47
AKTIV na CPU : 2 - 20220810 14:59:47
AKTIV na CPU : 2 - 20220810 14:59:48
AKTIV na CPU : 2 - 20220810 14:59:49
AKTIV na CPU : 2 - 20220810 14:59:50
AKTIV na CPU : 2 - 20220810 14:59:51
AKTIV na CPU : 2 - 20220810 14:59:52
AKTIV na CPU : 2 - 20220810 14:59:53
AKTIV na CPU : 2 - 20220810 14:59:54
AKTIV na CPU : 2 - 20220810 14:59:55
AKTIV na CPU : 2 - 20220810 14:59:56
AKTIV na CPU : 2 - 20220810 14:59:57
AKTIV na CPU : 2 - 20220810 14:59:58
STOP na CPU : 2 - 20220810 14:59:58

here is how read last time of activity and time difference
poziciaaktiv:=rat("AKTIV",cSourcestring)
aktivdattim:=substr(cSourcestring,poziciaaktiv,poziciastop-poziciaaktiv)
aktivdat:=substr(aktivdattim,at("-",aktivdattim)+2,8) // dátum
aktivtim:=substr(aktivdattim,at("-",aktivdattim)+2+8+1,8) // čas
rozdieltime:=timetosec(time())-timetosec(aktivtim) // rozdiel oproti aktuálnemu času

It will be interesting how it behaves on a server with heavy load and 12 core CPU ;)

Re: filetime and filedate in directory

Posted: Fri Aug 12, 2022 12:33 am
by skiman
Hi Victorio,

Two remarks:
- Writing every 1 second is maybe time consuming? And it makes your TIM file bigger which can also slow down the processing of the file to check if it is ready?
- If the word STOP is in the file, you are also sure it is finished.

Code: Select all

if !'STOP' $ cSourcestring
	poziciaaktiv:=rat("AKTIV",cSourcestring)
	aktivdattim:=substr(cSourcestring,poziciaaktiv,poziciastop-poziciaaktiv)
	aktivdat:=substr(aktivdattim,at("-",aktivdattim)+2,8) // dátum
	aktivtim:=substr(aktivdattim,at("-",aktivdattim)+2+8+1,8) // čas
	rozdieltime:=timetosec(time())-timetosec(aktivtim) // rozdiel oproti aktuálnemu času
else
	lFinished := .T.	
endif
Every millisec. can make a difference in this kind of program flow.

Re: filetime and filedate in directory

Posted: Fri Aug 12, 2022 5:40 am
by Victorio
Chris,

1 second is only example, in real use this will be set to 10 or more minutes. my client add about 10 - 15 processes afternoon to run it at night. At morning he has results. But when some of process frozen, or crash, he has not any result. This solution I want use to prevent waiting main program to any process, which does not report for a longer time, and interrupts it to can run other process.
Because processes run on 12 core CPU, and use 100% his performance, sometimes one from it crashes, or freezes.

I am thinking of a better system that would use some windows system variable, without the need to create external files, which is a bit temporary, although functional.
It would be possible to use something in the registries, but sometimes there is a problem with access to loading and writing in different versions of windows.
I won't complicate my life with it for now :naughty: