When I shut down my computer I want to show some pending tasks that I have to do before leaving the office...

I did a local application to manage those tasks, so basically I just want to run a command, and shut down after I kill the app executed.

I have already tried with these options:

  • /etc/gdm/PostSession/Default --> this works only when I select LogOut option instead Shutdown.

  • /etc/rc0.d/K01mycustomscript --> execute script after X is killed

  • $HOME/.bash_logout --> This looks like does nothing.

  • ./app-to-run && sudo shutdown -h now --> Don't like it for 2 reasons, prompts for sudo password, and can't use my laptop shutdown button.

I am using Ubuntu 10.04.

link|improve this question

75% accept rate
Is it really when you shut down, or do you mean when you log out of the GUI? – David Zaslavsky Aug 11 '10 at 1:41
Did any of the answers work for you? If so, will you "accept" one? – Adam Monsen Mar 3 '11 at 17:23
No one worked, I think the way to go is modifying the "Shut Down Computer" windows, but that would involve to recompile Gnome I think. I looked for changing the behavior of SHutDown button, but didn't find the way to run my app. – juanefren Mar 3 '11 at 17:58
feedback

4 Answers

You could make an init script in /etc/init.d/ and then configure on which runlevel you want it with chkconfig. I never did what you want, but I would start on this route.

link|improve this answer
feedback

Check out /etc/rc0.d/README

link|improve this answer
feedback
  • /etc/rc0.d/K01mycustomscript might need to be /etc/rc0.d/S01mycustomscript
  • make sure it is executable (chmod 755 /etc/rc0.d/K01mycustomscript or chmod 755 /etc/rc0.d/S01mycustomscript)
  • try some logging: add the line logger 'mycustomscript START' to the beginning of your script, and logger 'mycustomscript END' to the end, shutdown, then look for your log messages in /var/log/messages
  • note that the convention is instead to create a start/stop script in /etc/init.d/, then create symlinks to that script from the appropriate /etc/rc*.d directories, or to use a tool like chkconfig or update-rc.d to maintain the symlinks (see "Init" wikipedia page)
  • see this similar question
link|improve this answer
feedback
  • Put your executable script somewhere, /etc/init.d is recommended.
  • Make a symbolic link from this place from /etc/rc0.d, starting with S (to start this script when getting to runlevel 0.
  • I assume that the machine will wait for this script to terminate before shutting down, though I have never tested this.
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.