Unplug powersupply of RB750 v3, file with scheduler is 0 byte on restart

Hello,

When I create a file to enter data, regularly via a task scheduler (10 min) I have no problem.

When I restart the RB750 v3 via Winbox, my file is correct with the data I entered previously.

On the other hand, if there is a power failure, or if I unplug the RB750 v3, the file is at 0.

Why ?

Script 1 : statistique_queue

:global newFileContents "";
:global traf;
:global namevlan;
:global megsu "0";
:global megsd "0";
:global resulter " ";
:global logmsg;
:global datum [/system clock get date];
:global vrijeme [/system clock get time];
:global filenamess;
#:put "$datum - $vrijeme";
/queue tree
:foreach o in=[/queue tree find] do={
:set traf [get $o bytes];
:if ($traf > 0) do={
:set logmsg "";
:set traf [get $o bytes];
:set namevlan [get $o value-name=name];
:set megsd ($traf / 1024 / 1024)
#:put "$namevlan : $megsd Mo";
:set newFileContents ($newFileContents . $datum . ";" . $vrijeme . ";" . $namevlan . ";" . $megsd . ";" ."Mo\n");
}
}
/file print file=$filenamess;
:delay 2;
/file set $filenamess contents=$newFileContents;

Script 2 : onstartscript

:global basefilename test;
:local filenamess test;
:local tmp test;
:local count 0;

:while ([:len [/file find name="$filenamess".".txt"]] > 0) do={

:set filenamess ($basefilename.$count);
:set tmp ($basefilename.$count);
:set count ($count +1);

};
:global filenamess $tmp;
:put $filenamess;

Schedule schedule1 (on start)

/system scheduler disable schedule2
:delay 120;
/system script run onstartscript
/system scheduler enable schedule2

Schedule schedule2 (10 min)

/system script run statistique_queue

Best regards.

The file is in RAM. So it is lost on power failure.
Use the flash or attach external storage (USB stick, SD card).

Thank you pe1chl,

My problem is solved.

Best regards.