filetime and filedate in directory

This forum is for eXpress++ general support.
Message
Author
Wolfgang Ciriack
Posts: 481
Joined: Wed Jan 27, 2010 10:25 pm
Location: Berlin Germany

Re: filetime and filedate in directory

#11 Post 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.
_______________________
Best Regards
Wolfgang

User avatar
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

#12 Post 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

User avatar
Auge_Ohr
Posts: 1422
Joined: Wed Feb 24, 2010 3:44 pm

Re: filetime and filedate in directory

#13 Post 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
greetings by OHR
Jimmy

Victorio
Posts: 633
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

Re: filetime and filedate in directory

#14 Post 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 ;)

skiman
Posts: 1195
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: filetime and filedate in directory

#15 Post 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.
Best regards,

Chris.
www.aboservice.be

Victorio
Posts: 633
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

Re: filetime and filedate in directory

#16 Post 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:

Post Reply