Community discussions

 
martin3444
just joined
Topic Author
Posts: 20
Joined: Tue Jul 24, 2018 1:58 am

Problem running script(s)

Tue Jul 24, 2018 2:25 am

Hello,

I have quite a weird problem with running my scripts.

Problem:
I have a script, that basically runs every day at 3AM and takes a backup from my router.
It works perfectly fine, but after some time (1 day or more) the script stops working. With error message: script error: action failed (6).

I've found a temporary solution for that. If I restart my router, then this script works fine again. But I really don't want to restart my router every day.

Script:
:global getDateTime do={
  :local thisdate [/system clock get date];
  :local year [:pick $thisdate 7 11];
  :local month [:pick $thisdate 0 3];
  
  :if ($month="jan") do={[:set $month "01"]};
  :if ($month="feb") do={[:set $month "02"]};
  :if ($month="mar") do={[:set $month "03"]};
  :if ($month="apr") do={[:set $month "04"]};
  :if ($month="may") do={[:set $month "05"]};
  :if ($month="jun") do={[:set $month "06"]};
  :if ($month="jul") do={[:set $month "07"]};
  :if ($month="aug") do={[:set $month "08"]};
  :if ($month="sep") do={[:set $month "09"]};
  :if ($month="oct") do={[:set $month "10"]};
  :if ($month="nov") do={[:set $month "11"]};
  :if ($month="dec") do={[:set $month "12"]};
  
  :local day [:pick $thisdate 4 6];
  :local datetimestring ([$day] . "." . [$month] . "." . [$year]);
  
  :return ($datetimestring)

}

/system backup save name=("disk1/backups/" . [$getDateTime] . ".backup")
/export file=("disk1/backups/" . [$getDateTime] . ".rsc")

Router information:
Model: 951G-2HnD
Firmware: 6.42.6
RouterOS: 6.42.6

PS: I've only added one script, because other scripts have the same problem.
 
martin3444
just joined
Topic Author
Posts: 20
Joined: Tue Jul 24, 2018 1:58 am

Re: Problem running script(s)

Tue Jul 24, 2018 11:00 pm

Anyone?
 
User avatar
dasiu
Trainer
Trainer
Posts: 232
Joined: Fri Jan 30, 2009 11:41 am
Location: Reading, UK
Contact:

Re: Problem running script(s)

Wed Jul 25, 2018 9:20 pm

Tried using local instead of global? Not ":global getDateTime" but ":local getDateTime"? If you have few scripts and they all have this function - they overwrite it and maybe it's causing the problem if they are doing it in the same time?
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 217
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: Problem running script(s)

Wed Jul 25, 2018 10:40 pm

Tried using local instead of global? Not ":global getDateTime" but ":local getDateTime"? If you have few scripts and they all have this function - they overwrite it and maybe it's causing the problem if they are doing it in the same time?
+1
Try
:do {
:local getDateTime do={
  :local thisdate [/system clock get date];
  :local year [:pick $thisdate 7 11];
  :local month [:pick $thisdate 0 3];
  
  :if ($month="jan") do={[:set $month "01"]};
  :if ($month="feb") do={[:set $month "02"]};
  :if ($month="mar") do={[:set $month "03"]};
  :if ($month="apr") do={[:set $month "04"]};
  :if ($month="may") do={[:set $month "05"]};
  :if ($month="jun") do={[:set $month "06"]};
  :if ($month="jul") do={[:set $month "07"]};
  :if ($month="aug") do={[:set $month "08"]};
  :if ($month="sep") do={[:set $month "09"]};
  :if ($month="oct") do={[:set $month "10"]};
  :if ($month="nov") do={[:set $month "11"]};
  :if ($month="dec") do={[:set $month "12"]};
  
  :local day [:pick $thisdate 4 6];
  :local datetimestring ([$day] . "." . [$month] . "." . [$year]);
  
  :return ($datetimestring)
}

:do {/system backup save name=("disk1/backups/" . [$getDateTime] . ".backup")} on-error={:log warning message="Backup failed..."}
:do {/export file=("disk1/backups/" . [$getDateTime] . ".rsc")} on-error={:log warning message="Export failed..."}
} on-error={:log warning message="Script failed..."}



and see log for error report
 
martin3444
just joined
Topic Author
Posts: 20
Joined: Tue Jul 24, 2018 1:58 am

Re: Problem running script(s)

Thu Jul 26, 2018 1:57 am

Tried using local instead of global? Not ":global getDateTime" but ":local getDateTime"? If you have few scripts and they all have this function - they overwrite it and maybe it's causing the problem if they are doing it in the same time?
+1
Try
:do {
:local getDateTime do={
  :local thisdate [/system clock get date];
  :local year [:pick $thisdate 7 11];
  :local month [:pick $thisdate 0 3];
  
  :if ($month="jan") do={[:set $month "01"]};
  :if ($month="feb") do={[:set $month "02"]};
  :if ($month="mar") do={[:set $month "03"]};
  :if ($month="apr") do={[:set $month "04"]};
  :if ($month="may") do={[:set $month "05"]};
  :if ($month="jun") do={[:set $month "06"]};
  :if ($month="jul") do={[:set $month "07"]};
  :if ($month="aug") do={[:set $month "08"]};
  :if ($month="sep") do={[:set $month "09"]};
  :if ($month="oct") do={[:set $month "10"]};
  :if ($month="nov") do={[:set $month "11"]};
  :if ($month="dec") do={[:set $month "12"]};
  
  :local day [:pick $thisdate 4 6];
  :local datetimestring ([$day] . "." . [$month] . "." . [$year]);
  
  :return ($datetimestring)
}

:do {/system backup save name=("disk1/backups/" . [$getDateTime] . ".backup")} on-error={:log warning message="Backup failed..."}
:do {/export file=("disk1/backups/" . [$getDateTime] . ".rsc")} on-error={:log warning message="Export failed..."}
} on-error={:log warning message="Script failed..."}



and see log for error report
Hello and thank you for your answers. I'll test your modified script and replay after some days.
 
martin3444
just joined
Topic Author
Posts: 20
Joined: Tue Jul 24, 2018 1:58 am

Re: Problem running script(s)

Thu Jul 26, 2018 4:59 pm

Tried using local instead of global? Not ":global getDateTime" but ":local getDateTime"? If you have few scripts and they all have this function - they overwrite it and maybe it's causing the problem if they are doing it in the same time?
+1
Try
:do {
:local getDateTime do={
  :local thisdate [/system clock get date];
  :local year [:pick $thisdate 7 11];
  :local month [:pick $thisdate 0 3];
  
  :if ($month="jan") do={[:set $month "01"]};
  :if ($month="feb") do={[:set $month "02"]};
  :if ($month="mar") do={[:set $month "03"]};
  :if ($month="apr") do={[:set $month "04"]};
  :if ($month="may") do={[:set $month "05"]};
  :if ($month="jun") do={[:set $month "06"]};
  :if ($month="jul") do={[:set $month "07"]};
  :if ($month="aug") do={[:set $month "08"]};
  :if ($month="sep") do={[:set $month "09"]};
  :if ($month="oct") do={[:set $month "10"]};
  :if ($month="nov") do={[:set $month "11"]};
  :if ($month="dec") do={[:set $month "12"]};
  
  :local day [:pick $thisdate 4 6];
  :local datetimestring ([$day] . "." . [$month] . "." . [$year]);
  
  :return ($datetimestring)
}

:do {/system backup save name=("disk1/backups/" . [$getDateTime] . ".backup")} on-error={:log warning message="Backup failed..."}
:do {/export file=("disk1/backups/" . [$getDateTime] . ".rsc")} on-error={:log warning message="Export failed..."}
} on-error={:log warning message="Script failed..."}



and see log for error report
Hello and thank you for your answers. I'll test your modified script and replay after some days.
Hello!

The script works BUT after some time it does not work again. But I accidentally stumbled upon a problem that my flash drive, where these backups go, is read only.
When I restart my router, then the flash drive is perfectly fine but after some time it is read only again. Can't even delete files from there.

I'm trying a different flash drive, maybe it's dying.

Thank you.
 
martin3444
just joined
Topic Author
Posts: 20
Joined: Tue Jul 24, 2018 1:58 am

Re: Problem running script(s)  [SOLVED]

Thu Aug 02, 2018 10:08 pm

New flash drive solved the problem.

Thank you all!

Who is online

Users browsing this forum: MSN [Bot] and 18 guests