Community discussions

 
fahedksa
Member Candidate
Member Candidate
Topic Author
Posts: 107
Joined: Mon Nov 27, 2006 2:27 pm

How to run script auto after restart

Sat Jan 17, 2009 4:18 pm

Hay,
How i can make script to run automatic after restart?
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: How to run script auto after restart

Sun Jan 18, 2009 12:21 am

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.
 
fahedksa
Member Candidate
Member Candidate
Topic Author
Posts: 107
Joined: Mon Nov 27, 2006 2:27 pm

Re: How to run script auto after restart

Sun Jan 18, 2009 9:56 am

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?
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: How to run script auto after restart

Sun Jan 18, 2009 10:51 am

Does the script send the email if you run it after the boot? Or does it always fail?
 
fahedksa
Member Candidate
Member Candidate
Topic Author
Posts: 107
Joined: Mon Nov 27, 2006 2:27 pm

Re: How to run script auto after restart

Sun Jan 18, 2009 10:57 am

if i run script after reboot its work and send email without any problem
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: How to run script auto after restart

Sun Jan 18, 2009 12:46 pm

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.
 
fahedksa
Member Candidate
Member Candidate
Topic Author
Posts: 107
Joined: Mon Nov 27, 2006 2:27 pm

Re: How to run script auto after restart

Sun Jan 18, 2009 12:55 pm

Thank you for your reply.
its mean to be like that

delay 10
/system script run logtofile
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: How to run script auto after restart

Sun Jan 18, 2009 1:00 pm

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.
 
fahedksa
Member Candidate
Member Candidate
Topic Author
Posts: 107
Joined: Mon Nov 27, 2006 2:27 pm

Re: How to run script auto after restart

Sun Jan 18, 2009 1:09 pm

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])
Last edited by fahedksa on Sun Jan 18, 2009 1:38 pm, edited 1 time in total.
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: How to run script auto after restart

Sun Jan 18, 2009 1:21 pm

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
 
fahedksa
Member Candidate
Member Candidate
Topic Author
Posts: 107
Joined: Mon Nov 27, 2006 2:27 pm

Re: How to run script auto after restart

Sun Jan 18, 2009 1:39 pm

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])

Who is online

Users browsing this forum: No registered users and 14 guests