Community discussions

MikroTik App
 
pasan
just joined
Topic Author
Posts: 3
Joined: Thu Aug 25, 2016 4:16 am

Writing script output to non-volatile storage "/flash"

Thu Aug 25, 2016 4:34 am

Hi, I recently started using a Mikrotik hex router and this is my first foray into Mikrotik gear. I am pretty impressed with the depth of options available with this router. Anyhow, I studied a bit of scripting using various sources to write a script that would log my WAN interface data usage (rx + tx) at mid night every night so I can keep my ISP honest about how much I am being charged. Now I know all the stats get cleared during a power reboot but to my dismay I found that files also get wiped during power cycle unless it is stored within the /flash directory.

The problem is I can't figure out how to create a file at /flash and then read and write to it. Well i Kind figured out how to create it
/file print file=/flash/datausage
but I cannot write to it using
/file set /flash/datausage.txt contents="blah blah"}
.
I also tried using
/disk
commands but no luck.

I'd like to keep stats for a month at least and it is no use if the stats stored on a file gets wiped during a simple reboot. I have looked through on-line resources and forum threads here but similar questions have never been answered to. I don't know whether it is a polite way of saying no or it is too much of a can of worms! And before you say, do it the right way and use rrdtools, it is just overkill for my simple purpose. For the time being I have a daily email being sent out with the day's data use but I would really love to be able to log this on a file so my inbox isn't messy.

So is it possible to create and write files to non-volatile memory within this router?