Hay,
How i can make script to run automatic after restart?
If your script is called ‘test’:
/system schedule
add name=test on-event=test start-time=startup interval=0
This will run 3 seconds after bootup. See the docs under System Scheduler for more info.
Thank you for your reply
i ty your script and its execute after i restart but its give me error
10:44:47 system,e-mail,error Error sending e-mail: error connecting to server
may be becuase its executed after 3 seconds only ?can i make it run after 10 seconds from restart?
Does the script send the email if you run it after the boot? Or does it always fail?
if i run script after reboot its work and send email without any problem
You probably just need a few seconds to establish the connections. Try this for the first line of your script:
delay 10
That should wait 10 seconds, then execute the rest of the script. If that is not enough, increase the number a little.
Thank you for your reply.
its mean to be like that
delay 10
/system script run logtofile
That line should be in the script where your code is that sends the email.
/system script
It should be the first line in the logtofile script.
ADD: Now when you run the script
/system script run logtofile
it should take at least ten seconds to complete.
Can you please check if these right now:
shedule
add comment=“” disabled=no interval=0s name=LogafterStartup on-event=
“/system script run logtofile” start-time=startup
script
delay 10;
/log print file=([/system identity get name] . “Log-” . [:pick [/system clock get date] 7 11] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6]);
/tool e-mail send to=“xxx@xxx.com” subject=([/system identity get name] . " Log " .
[/system clock get date]) file=([/system identity get name] . “Log-” . [:pick [/system clock get date] 7 11] .
[:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6] . “.txt”); :delay 10;
/file rem [/file find name=([/system identity get name] . “Log-” . [:pick [/system clock get date] 7 11] .
[:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6] . “.txt”)];
:log info ("System Log emailed at " . [/sys cl get time] . " " . [/sys cl get date])
Almost! All you need is the script name. It must be in /system script, or the scheduler won’t see it.
/system schedule
add disabled=no interval=0s name=LogafterStartup on-event=logtofile start-time=startup
Thank you Thank you Thank you
Its work now but there is a little change
{:delay 10};
/log print file=([/system identity get name] . “Log-” . [:pick [/system clock get date] 7 11] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6]);
/tool e-mail send to=“xxx@xxx.com” subject=([/system identity get name] . " Log " .
[/system clock get date]) file=([/system identity get name] . “Log-” . [:pick [/system clock get date] 7 11] .
[:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6] . “.txt”); :delay 10;
/file rem [/file find name=([/system identity get name] . “Log-” . [:pick [/system clock get date] 7 11] .
[:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6] . “.txt”)];
:log info ("System Log emailed at " . [/sys cl get time] . " " . [/sys cl get date])