weird Matlab+Windows Scheduler Behavior

9 visualizaciones (últimos 30 días)
Christopher Hunt
Christopher Hunt el 13 de Abr. de 2022
Respondida: Tharikaa Ramesh Kumar el 12 de Jun. de 2024
I have a simple .m script I want to run each hour through Windows Scheduler. I've done this before on other systems, but this is on a new-to-me Win11 computer, Matlab R2022. When I try to use Windows Scheduler I get two strange results:
  1. Matlab command line window opens with a warning that it doesn't recognize the -r argument
  2. The command line window then just sits there, and won't run my script. It is running in the correct working directory, and the script it there, but it's like the argument with the script name doesn't get passed.
I've tried putting "run scriptname" into the Windows Scheduler argument field (where -nosplash and -nodisplay seem to work fine), but no luck. Any ideas?
  3 comentarios
Christopher Hunt
Christopher Hunt el 14 de Abr. de 2022
Sure, I understand...I'll post some images of the Scheduler setup, perhaps that will help.
In Scheduler, the Action is set to "Start a Program"
The "Program/Script" is set to "C:\Program Files\MATLAB\R2022a\bin\win64\matlab.exe" (with the quotes)
The Add Arguments is set to -r -nodesktop -nosplash "run GBB_lvl1"
The Start In is set to the directory with the GBB_lvl1.m script: C:\Users\whguser\OneDrive - USNH\Documents\MATLAB\work
Tharikaa Ramesh Kumar
Tharikaa Ramesh Kumar el 12 de Jun. de 2024
Do you run time-consuming tasks on MATLAB and Simulink? Do you wish you could schedule them and run them in the background, unattended? How do you solve this question today?
MATLAB Product team is very interested to talk to you and learn from your experience. Please participate in this brief survey (6 questions).

Iniciar sesión para comentar.

Respuesta aceptada

Steven Lord
Steven Lord el 14 de Abr. de 2022
The Add Arguments is set to -r -nodesktop -nosplash "run GBB_lvl1"
So you're telling MATLAB to run a command (with the -r option) and then immediately starting with the next option, -nodesktop. That means there's no actual command for MATLAB to run.
Try swapping the order around to -nodesktop -nosplash -r "run GBB_lvl1"
Alternately you might want to use the -batch option instead of having to specify all three of those options.
  1 comentario
Christopher Hunt
Christopher Hunt el 14 de Abr. de 2022
Fantastic! That did it, thanks Steve. In an older Matlab version (R2019b) and older version on Windows (Win7) I was able to start off with the -r argument and then have -nosplash and -nodesktop before the script name. The help is much appreciated!

Iniciar sesión para comentar.

Más respuestas (1)

Tharikaa Ramesh Kumar
Tharikaa Ramesh Kumar el 12 de Jun. de 2024
Do you run time-consuming tasks on MATLAB and Simulink? Do you wish you could schedule them and run them in the background, unattended? How do you solve this question today?
MATLAB Product team is very interested to talk to you and learn from your experience. Please participate in this brief survey (6 questions).

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by