max not quitting properly
i want to set up a mac to turn on in the morning, automatically load a max patch, play it for the day then shut down in the evening.
at the moment i've done this by setting up the starting up and shutting down in system preferences -> energy saver -> schedule. and in user accounts -> startup items, i have the patch. it's working ok but is this the best way to do it? the only problem is that on some but not all days, it's left with a "max msp could not be shut down" error message at the end of the day, which stops the whole computer from shutting down (and messes up the next day because it wasnt started again from scratch).
thanks.
did you mail support about this?
jrp
I'm not sure why that's happening, but a possible workaround would be to use the [date] object to figure out how long the patch has been open, for the purpose of closing the patch (i.e. using the dispose message to thispatcher) a couple minutes before the computer shuts down. I think you'd be more likely to have Max quit properly if there weren't any patches open.
Although, is there a reason you want to shut the computer down every night? I often leave my computers on all the time... They use relatively little power, and some people argue that leaving them on all the time extends their life, because the internal circuit boards would rather see a constant temperature than a daily cycle of warm and cold temperatures, which eventually stresses the microscopic layer of glass on the circuit boards.
yes (seconding swieser) you could leave your computer on and use the [date] object to
1. stop the patch, when the day is over
2. reset the patch to its starting condition
3. start it over, when you reached a certain day time.
or you could use a timed brute-force apple script to force-quit max a few mins before the computer shuts down.
jrp
thanks for the help. i didnt mail support.. should i?
leaving the computer on seems like a good idea, i might try that.
alternatively how do i set an applescript to run at a specific time each day? and is there a force quit that will ignore "cannot close" type errors?
the third thing is to make sure all the patches are closed - is this best done with dispose messages to thispatcher objects?
This applescript should do what you need. You just need to edit the open and close times and the path of the file you want to use. I haven't tested to see whether it will close Max if a patch with unsaved edits is open but if you are simply running one patch all day this shouldn't be an issue. There might be simpler/less processor intensive ways to do this. I've tried to work it so that it only queries the time every minute rather than always. I hope it helps.
lh
-- set opening time hours and minutes
set startHour to "09"
set startMin to "00"
set startTime to (startHour * 3600) + (startMin * 60) -- convert to seconds
repeat
if seconds of (current date) is not 1 then -- query time every minute
set delTime to "0"
else
set delTime to "60"
end if
delay delTime
set timeNow to time of (current date)
if timeNow > startTime then exit repeat -- is it time?
end repeat
tell application "Finder"
open file "Macintosh HD:Users:username:Folder:AnotherFolder:YetAnotherFolder:filename" -- open file
end tell
-- set closing time hours and minutes
set endHour to "18"
set endMin to "00"
set endTime to (endHour * 3600) + (endMin * 60) -- convert to seconds
repeat
if minutes of (current date) is not 1 then -- query time every minute
set delTime to "60"
else
set delTime to "0"
end if
delay delTime
set timeNow to time of (current date)
if timeNow > endTime then exit repeat -- is it time?
end repeat
tell application "MaxMSP"
quit -- close MaxMSP
end tell
if you're worried about closing a patch with unsaved edits, just send the "clean" message to thispatcher.
that's great, thanks very much. but is "tell application "MaxMSP" quit" really any different to the instruction it will receive when the computer shuts down?
Quote: thereishopeforus@hotmail.com wrote on Sun, 23 November 2008 16:55
----------------------------------------------------
> This applescript should do what you need. You just need to edit the open and close times and the path of the file you want to use. I haven't tested to see whether it will close Max if a patch with unsaved edits is open but if you are simply running one patch all day this shouldn't be an issue. There might be simpler/less processor intensive ways to do this. I've tried to work it so that it only queries the time every minute rather than always. I hope it helps.
>
> lh
>
>
> -- set opening time hours and minutes
> set startHour to "09"
> set startMin to "00"
> set startTime to (startHour * 3600) + (startMin * 60) -- convert to seconds
> repeat
> if seconds of (current date) is not 1 then -- query time every minute
> set delTime to "0"
> else
> set delTime to "60"
> end if
> delay delTime
> set timeNow to time of (current date)
> if timeNow > startTime then exit repeat -- is it time?
> end repeat
> tell application "Finder"
> open file "Macintosh HD:Users:username:Folder:AnotherFolder:YetAnotherFolder:filename" -- open file
> end tell
>
> -- set closing time hours and minutes
> set endHour to "18"
> set endMin to "00"
> set endTime to (endHour * 3600) + (endMin * 60) -- convert to seconds
> repeat
> if minutes of (current date) is not 1 then -- query time every minute
> set delTime to "60"
> else
> set delTime to "0"
> end if
> delay delTime
> set timeNow to time of (current date)
> if timeNow > endTime then exit repeat -- is it time?
> end repeat
> tell application "MaxMSP"
> quit -- close MaxMSP
> end tell
>
>
----------------------------------------------------
I'm not really sure. You could always script a force quit from the apple menu using system events to control the user interface, but that's a bit beyond me at the moment. If you used system events you could also close any max files that asked you if you want to save changes.
It would help if you knew why max isn't quitting properly.
If you want to close the computer down after quitting max you can do that from inside the applescript, which would hopefully ensure that everything is shut down properly.
lh
-- shut down
delay 120
tell application "Finder" to shut down
> It would help if you knew why max isn't quitting properly.
the trouble is, it's so "undeterministic" that i can't recreate it, it just happens very occasionally (but more than once).
> If you want to close the computer down after quitting max you can do that from inside the applescript, which would hopefully ensure that everything is shut down properly.
ok i'll give it a go, thanks again.
I've been going through Apple script and Terminal tutorials a bit, and it seems, that
tell application "someapp"
quit
is likely to be not more effective against your randomly appearing problem, than using the procedure you used at first, as apple script uses the same shutdown mechanism as the system.
terminal then would offer a way to force-quit maxmsp, nevertheless it is not simple to establish, and there's several drawbacks involved, including accidental damage of your hard disk.
one thing that just occurred to me is, that yur energy saving settings should be set to not spin down the hard disk at any point, as well as not enter sleep more or even turn down the screen. id you experiment with that?
otherwise i don't really want to generate more support requests to c74, but you might really want to ask for in-depth help from them on this problem, as they might be able to point out the parts in your patch, where unsaved data might pile up during the day of running it. if that's the culprit.
following this thread i find, that the culprit still hasn't been found.
jrp
Quote: stefantiedje wrote on Sun, 23 November 2008 23:39
----------------------------------------------------
> Scott schrieb:
> > Although, is there a reason you want to shut the computer down every
> > night? I often leave my computers on all the time... They use
> > relatively little power, and some people argue that leaving them on
> > all the time extends their life, because the internal circuit boards
> > would rather see a constant temperature than a daily cycle of warm
> > and cold temperatures, which eventually stresses the microscopic
> > layer of glass on the circuit boards.
>
> I only know this argument for mixing tables, and it does not extend
> their life, the argument is more an esoteric believe that they sound
> better if you leave them on...
> Computers will live shorter, especially notebooks. Desktops use A LOT of
> power, they are often that badly made, that you would even have to cut
> the mains, as they still drain a lot of power if the cord is still
> connected. Laptops don't do that, but you will kill the battery if its
> hot all day.
> On a Mac you could set it to sleep, instead of shutting down, that
> doesn't require closing the application btw...
>
> Stefan
I'll agree that this is a long-debated topic for which there are almost equal proponents on both sides. The only reason I'm on the "leave the computer on" side is because I once talked to a high-level computer hardware engineer who was on that side. Nevertheless, there is very little (if any) experimental evidence to back up either side of the argument.
As far as power draw from a computer goes, I said that a computer draws *relatively* little power, i.e. relative to an audio amplifier or theatrical lighting or something. In the grand scheme of the power that a particular building is using, one computer being left on overnight is like accidentally leaving a desk lamp on at the pentagon. The power savings for the building would barely be measurable at that level.
Also, as I said before, if Max isn't quitting because there are unsaved changes in the patch, and you just end up with a "Do you want to save changes before you quit?" dialog box which stalls your shutdown process, then just send a "clean" message to thispatcher to prevent that from happening.
It might be a good idea to do a big coordinated shutdown process that has a better chance of succeeding, in other words, at 9pm send a "clean" message to thispatcher, send a "dispose" message to thispatcher, and that should close the patch. Then at 9:05pm, use an applescript to shut down max. Then, at 9:10pm have a scheduled shutdown of the computer from within the OS, etc. rather than just depending on the scheduled shutdown to do everything on its own.
Quote: swieser1 wrote on Mon, 24 November 2008 07:52
> Also, as I said before, if Max isn't quitting because there are unsaved changes in the patch, and you just end up with a "Do you want to save changes before you quit?" dialog box which stalls your shutdown process, then just send a "clean" message to thispatcher to prevent that from happening.
ah, but this isn't the message i've seen - it just says "max msp could not be closed" or something along those lines, nothing about unsaved changes. so perhaps i can rule out the alterations to the patch theory. i wish i could learn more about why it's happening but that would involve watching it carefully for days.. instead, i think i should just go for a solution that somehow manages to shut down the whole computer even if a dialog box is up.
On 24 Nov 2008, at 14:52, Scott wrote:
> Also, as I said before, if Max isn't quitting because there are
> unsaved changes in the patch, and you just end up with a "Do you
> want to save changes before you quit?" dialog box which stalls your
> shutdown process, then just send a "clean" message to thispatcher to
> prevent that from happening.
This may be a daft suggestion (and sorry if I missed the start of the
thread) - but why not just use Max Runtime?
-- N.
Nick Rothwell / Cassiel.com Limited
www.cassiel.com
www.myspace.com/cassieldotcom
www.last.fm/music/cassiel
www.reverbnation.com/cassiel
www.linkedin.com/in/cassiel
www.loadbang.net
Quote: nick rothwell / cassiel wrote on Mon, 24 November 2008 09:01
----------------------------------------------------
> This may be a daft suggestion (and sorry if I missed the start of the
> thread) - but why not just use Max Runtime?
this sounds like a very sensible idea.