Community discussions

MikroTik App
User avatar
Long time Member
Long time Member
Topic Author
Posts: 603
Joined: Mon Jan 16, 2006 6:07 am
Location: Norwalk, CT

Persistent Environment Variables

Wed Dec 09, 2020 6:47 pm

other than to load them with a script every reboot, is there any way to get an environment variable to persist between multiple reboots?
Forum Guru
Forum Guru
Posts: 2044
Joined: Tue Feb 18, 2014 12:56 am
Location: Netherlands / Nīderlande

Re: Persistent Environment Variables

Thu Dec 10, 2020 1:03 am

No, this was discussed in the 7.1beta3 thread a few days ago.
Loving my freedom and so, no Twitter, no Facebook/Instagram/WhatsApp, no Apple and no Google/Alphabet, no Amazon/Cloudfront/AWS.

RouterOS 6.49Beta / Winbox 3.27 64bits
just joined
Posts: 2
Joined: Wed Sep 04, 2019 9:14 am
Location: China

Re: Persistent Environment Variables

Sat Jan 30, 2021 11:09 am

by baidu translate :
I have a method to define a schedule to read environment variables to the array every minute. In the definition of the second boot from the start of the schedule. Use the acquired array to write to the second schedule at any time. Maybe the idea is to make it by yourself

There is only one command to demonstrate :
:put [/system script environment print as-value ]
User avatar
Forum Guru
Forum Guru
Posts: 1915
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at

Re: Persistent Environment Variables

Sat Jan 30, 2021 1:12 pm

OP did not want a script or using scheduling.

I agree that there should be a way to set persistent variables that survives reboot.
You can add a fw rule it stays trough a reboot, so should a persistent variable do as well.
Last edited by Jotne on Mon Feb 08, 2021 3:48 pm, edited 1 time in total.
Why do not use Splunk to monitor your MikroTik Router(s)? Look at this page in how to set it up.

Posts: 332
Joined: Wed Mar 16, 2016 6:12 am

Re: Persistent Environment Variables

Mon Feb 08, 2021 6:17 am

For the moment you can kinda-sorta get away with it by storing variables as comments. The layer7-protocol area is not a bad one because it is practically unused these days so it doesn't clutter up the interface if you put a bunch of variables in there
Comments will not store arrays correctly, or rather the 'toarray' command to convert a string back to an array doesn't work because arrays store with semi-colon separates. Whereas the 'toarray' command uses commas to separate them (why mikrotik why?)

But this method works just fine for simpler things. I use it for incrementing a counter in a few scripts. One of them being a template that runs at a later time, where say a router is told to change some config and then reboot. Well the first command is to increment an integer in the comment of that scheduled task, it's first read and if the counter is higher than say 1 then something has gone wrong, commands havn't executed properly, script has failed, it failed to self-delete (otherwise its just going to reboot every single day at 3am forever) etc so it'll then send an email to support desk as well as a remote syslog message to alert that somethings not right and requires manual intervention

Who is online

Users browsing this forum: No registered users and 14 guests