On Wed, Oct 20, 2004 at 02:19:05PM +0100, Karl E. Jorgensen wrote: >On Wed, Oct 20, 2004 at 12:50:18AM +0200, Magnus Therning wrote: >> Currently I have a few jobs I run at boot time using @reboot in my >> crontab. I would really like to be able to run some jobs just before >> shutting down as well (alternatively when I log out of GNOME). How can I >> do that? > >To run them when you log out, you can put them in your ~/.xsession > > #!/bin/sh > gnome-session > ~/bin/job-to-run-after-logout 1 > ~/bin/job-to-run-after-logout 2 > >This will run the jobs after you log out of gnome. The jobs will still >ahve access to the X display - but there won't be any window manager at >this stage. > >The display manager won't return until the jobs are finished (unless >you start the jobs in the background, and then they cannot rely on >access to the the X display). > >PS: This assume that you actually use ~/.xsession - iirc you can tell > GDM to login as "X session" rather than the default gnome-session.
Hmm, this was a really good suggestion. I didn't do it exactly like this, instead I decided to put GDM to use. I added the following lines to /etc/gdm/PostSession/Default : if [ -x ${HOME}/.Xpost_session ]; then su - ${USER} --command=${HOME}/.Xpost_session fi The I put an executable script called .Xpost_session in my home directory. It basically has the following format: #! /bin/zsh job1 &>| ~/.Xpost_session.err job2 &>>| ~/.Xpost_session.err It all works wonderfully. Can it be done better, or more efficient? /M > >Hope this helps >-- >Karl E. Jørgensen >[EMAIL PROTECTED] http://karl.jorgensen.com >==== Today's fortune: >There's no saint like a reformed sinner. -- Magnus Therning (OpenPGP: 0xAB4DFBA4) [EMAIL PROTECTED] http://magnus.therning.org/ The corporation as we know it, which is now 120 years old, is unlikely to survive the next 25 years. Legally and financially yes, but not stucturally and economically. -- Peter Drucker
signature.asc
Description: Digital signature