You are not logged in.
Hi all,
I have created a bash script - which start recording a camera device for security purpose, but I need the script to finish when the security user is logging out.
Any idea on how to do that?
Offline
Isn't this how the scripts work by default?
http://www.xaprb.com/blog/2008/08/01/ho … u-log-out/
Last edited by karol (2011-02-16 09:11:24)
Offline
Before regarding any answers given, please define what the security user is
logging out from. A shell? A graphical environment? Some program? The answers
can differ a lot based on that information.
Offline
Hi all,
I have created a bash script - which start recording a camera device for security purpose, but I need the script to finish when the security user is logging out.
Any idea on how to do that?
If you use xdm for the login manager, I see from the man page that the Xreset (/etc/X11/xdm/Xreset) script is run. So you could kill the script from there. I suppose something similar must exist for other display manager.
Offline
The user is logging out of it's graphical session (gnome) using gdm.
So the computer stay up and running but the "security" user is logged out so the bash stop, ideally.
Many thanks for the quick replies
Offline
The user is logging out of it's graphical session (gnome) using gdm.
So the computer stay up and running but the "security" user is logged out so the bash stop, ideally.
Many thanks for the quick replies
I figured it'd be something like that. If you were using a .xinitrc/.xsession
file to start the security user's graphical environment, you could just omit the
often used 'exec' before the window manager command and call your script right
afterwards.
Unfortunately, gnome doesn't use these files and I don't know what exactly it
does use, so I'll pass this question on to my fellow Archers amongst whom there's
surely one to help you
Offline
Have you read my post about xdm? I do not use gdm but I see there http://superuser.com/questions/65460/cr … -for-linux (after a few minutes googling) that gdm use /etc/gdm/PostSession/Default after the session (similar to the Xreset for xdm). So just kill the script from there (I assume you know how to write bash scripts, send a signal with kill (or pkill) and depending on your script you may have have to intercept the signal for proper termination of you recording script).
Offline
Yes I had read your post - but it was late and I after a long train journey I just reply to the quick question.
Now I have fixed it, adding pkill mencoder to the /etc/gdm/PostSession/Default and it's done!
Many thanks,
Offline
Hi again,
This is working very well, but I have another issue - I would like to be able to "pkill mencoder" when shutting down the pc (using gnome menus) where is the script executed when shutting down or rebooting?
Many thanks
Offline
Hi again,
This is working very well, but I have another issue - I would like to be able to "pkill mencoder" when shutting down the pc (using gnome menus) where is the script executed when shutting down or rebooting?
Many thanks
/etc/rc.shutdown
Offline
Hi again,
sorry it took some time but I haven't had the time to look yet,
Back to the topic, I added the "pkill mencoder" at the begining of the file but it doesn't seem to work (because when shutting down the pc, the avi file created is broken - the index)
Any suggestion?
Offline
Hi again,
sorry it took some time but I haven't had the time to look yet,
Back to the topic, I added the "pkill mencoder" at the begining of the file but it doesn't seem to work (because when shutting down the pc, the avi file created is broken - the index)
Any suggestion?
Difficult to say like this. If you kill mencoder by hand (not with the logout script); does this work properly? Maybe you have to wait that men,coder actualy exit before continuing:
PID=$(grep mencoder)
kill $PID
wait $PID
(work only if there is a single mencoder process).
But how did you start mencoder? (o processes receive a HUP signal if the terminal from which it has been opened is closed).
Last edited by olive (2011-03-04 00:58:30)
Offline