Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

thriftinkid

macrumors regular
Original poster
Mar 24, 2008
119
0
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

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
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

macrumors G5
Jun 27, 2007
13,314
36
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

Guest
Dec 15, 2006
2,445
0
Montréal, Canada
off-topic, but...

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...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.