Run script when system shutdown

Hi Community,

I know the possibility in snow leopard to execute a script during system boot by using a launchd script located in /Library/LaunchDeamons or ~/Library/LaunchAgents but how can I configure a script which become executed on a system shutdown?

Thanks in advance & Bye Tom

MacPro, Mac OS X (10.6.3)

Posted on Jul 18, 2010 7:54 AM

Reply
7 replies

Jul 18, 2010 8:39 PM in response to prontosystems

This cheap one works(image) on my Leopard. I tried a rc.shutdown.local file but it would not activate the script. Just got the shutdown to work. So, I threw this one together, fwiw and varying mileage. And it did say goodbye. The sudo usage on shutdown is covered by previous sudoers change by me.
User uploaded file

But then it does what I want, and gets wiped out, so what did this accomplish? I guess it depends on the importance of one's script.

Jul 19, 2010 8:30 AM in response to prontosystems

Well then that is /etc/rc.local.shutdown that I believe you want. It won't trigger a shutdown, but on next restart, your commands will have been done. I just made a text file for /etc/rc.local.shutdown to cp from one file to another. Then I restarted manually and file was copied.
http://discussions.apple.com/thread.jspa?threadID=2214781&start=0&tstart=0
http://discussions.info.apple.com/message.jspa?messageID=11226121
http://www.google.com/search?rls=ig&hl=en&source=hp&q=rc.shutdown.localonmac&aq=f&aqi=&aql=&oq=&gsrfai=Cd4_sLWFETIzHK4zEiQOP4fjFCQAAAKoEBUQoQO5

Jul 19, 2010 1:18 PM in response to doug pennington

doug pennington wrote:
Well then that is /etc/rc.local.shutdown that I believe you want. It won't trigger a shutdown, but on next restart, your commands will have been done. I just made a text file for /etc/rc.local.shutdown to cp from one file to another. Then I restarted manually and file was copied.


Hi,

there are many Google hits about a rc.shutdown.local but neither this type of script nor your version rc.local.shutdown works. I put a tiny command in it which should create a file in /tmp but the script seems not to become executed. I can run this script manually and it works but not at shutdown.

Any ideas?

Jul 19, 2010 2:50 PM in response to Tony T1

Tony T1 wrote:
Isn't /tmp cleared upon restart? Try putting the test file in $HOME/Desktop


Really? This could be the reason why I lost another test file I put to /temp a few days ago. I had no idea why this file was gone but now... 😉

I will have a try but now I'm in a discussion with a colleagau about a presentation we have tomorrow. But thanks this could be really the reason why it won't work...

Bye Tom

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Run script when system shutdown

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.