필터 지우기
필터 지우기

How Can I set a program that can run my script at a particular day and time. If I keep my program running and computer turned on?

조회 수: 9 (최근 30일)
I have made a script that can send automatic mail to my recepients. But I want to sent a perticular day and time for the auto mail to be sent. Can some one help me with the code for my problem?

채택된 답변

Walter Roberson
Walter Roberson 2021년 2월 4일
편집: Walter Roberson 2021년 2월 4일
MATLAB does not offer an absolute time timer, only relative time timers. Your options are:
1) use Windows "at" or similar to command matlab be started to run a command, such as using the "batch" option. The timing is kept outside of MATLAB, but the program might take a minute to launch https://docs.microsoft.com/en-us/troubleshoot/windows-client/system-management-components/use-at-command-to-schedule-tasks
2) have a periodic timer() object that checks the current time and starts a file handle you have previously stored in a data object. Because the timer is likely to drift, you might not launch at exactly the time you want, but when you do start, the function will start immediately without having to wait for matlab to launch. The more often you schedule the timer, the more resources get used.
3) Use an adaptive scheduling of the timer, such as every 6 hours when it is not close to the launch time, but more and more frequently as the time approaches, paying attention to the difference between scheduled start and actual start to try to estimate drift and timer() overhead, with a goal of eventually starting the function as near as possible to the scheduled time. When you got close enough, you could launch slightly early and have the function pause() for just less than the time remaining before the scheduled time. You would only bother with this kind of trouble if it was important that the function start time was as close as possible to schedule.

추가 답변 (1개)

Adithya Narasimhan
Adithya Narasimhan 2021년 2월 4일
편집: Adithya Narasimhan 2021년 2월 4일
I have another question regarding the timer() commond can I specify a day and time for my script to be executed or is there any other approch.
  댓글 수: 1
Walter Roberson
Walter Roberson 2021년 2월 4일
No. As I said, there are no absolute time timers. You can only specify relative time to time the timer is started. "run 7 hours from now" , not "run at 1pm"

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Time Series Objects에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by