View Full Version : Remembering running program on shutdown
thriftinkid
Jan 5, 2009, 04:57 PM
I have my computer set up for an automatic shutdown and startup on a daily basis. I have a specific program that I would like to start up the next morning with my computer, but only if it had been running when the computer shutdown the night before. If not, it should not load up. Is there a way that I can add a section in my startup/shutdown script that will check for that, and execute it the next morning if need be? I'm writing in applescript. I know it's not particularly reliable, but then again, I'm not a programmer. So it's basically my crutch into this new world. Thanks guys!
lee1210
Jan 5, 2009, 05:01 PM
If you control the program (it doesn't sound like it) i would use a file to indicate if the program was running, and remove it otherwise.
Since you don't, i would take the tact of parsing the output of ps to see if the process is running at shutdown, and record whether it is or not with the contents of a file (or simply the presence or absence of a file). There may be a more "direct" means to see if a program is running in applescript, but i am not familiar enough with it to say. In any event, even if you can determine if the process is running in "pure" applescript, you'll still need a way to store this to pick up the value on the next run.
-Lee
EDIT: I thought of another option. You could always launch this program through a shell script. The script could touch a file, run the program in question, then delete the file when it's done. I guess it depends on when in the shutdown process your applescript ran. It would have to be before the OS kills the program so you can still see the file there.
Consultant
Jan 5, 2009, 05:18 PM
FYI, you DO NOT need to shut down OSX every day.
Have you tried SLEEP? For most users, restarts are only needed when there is a system software update.
Darkroom
Jan 5, 2009, 10:42 PM
honestly... i maybe restart my computer once a month...
command-option-eject is the only power button i truly know :p. although setting a top right hot corner to activate sleep works really well...
Cromulent
Jan 6, 2009, 01:22 AM
Apple actually specifically recommend not turning your computer on and off all the time. The only time you should turn it off is when you go away for a few days.
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.