PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > Running script after logging out of SSH
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

Running script after logging out of SSH

Réponse
 
LinkBack Outils de la discussion
Vieux 24/03/2008, 22h14   #1
laredotornado
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Running script after logging out of SSH

Hi,

I'm using Fedora Core Linux 6 and currently using zsh, but I can
change shells. What I'm wondering is how I would execute a script
after I have logged out via SSH. My normal way of working is to use
Putty on my Windows XP machine to SSH in to my Linux box. When I
click "exit" from Putty when logged in as user "me", I would like to
run a script that backs up certain files.

Thanks, - Dave
  Réponse avec citation
Vieux 25/03/2008, 00h11   #2
Greg Russell
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Running script after logging out of SSH

On Mon, 24 Mar 2008 14:14:20 -0700, laredotornado wrote:

> I'm using Fedora Core Linux 6 and currently using zsh, but I can change
> shells. What I'm wondering is how I would execute a script after I have
> logged out via SSH. My normal way of working is to use Putty on my
> Windows XP machine to SSH in to my Linux box. When I click "exit" from
> Putty when logged in as user "me", I would like to run a script that
> backs up certain files.


The "man zsh" page indicates that you want the executable script as a
command in $HOME/.zlogout. I doubt that the file will be parsed if you
exit PuTTY in the manner you state, so you should exit the zsh by typing
"exit" in the window, rather than the GUI exit you state. You'll have to
experiment to verify that behaviour.

  Réponse avec citation
Vieux 25/03/2008, 00h16   #3
Luuk
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Running script after logging out of SSH

laredotornado schreef:
> Hi,
>
> I'm using Fedora Core Linux 6 and currently using zsh, but I can
> change shells. What I'm wondering is how I would execute a script
> after I have logged out via SSH. My normal way of working is to use
> Putty on my Windows XP machine to SSH in to my Linux box. When I
> click "exit" from Putty when logged in as user "me", I would like to
> run a script that backs up certain files.
>
> Thanks, - Dave


type:
$ man zsh

and search for 'logout'
(by typeing '/logout'...)
you'll find the info there

--
Luuk
  Réponse avec citation
Vieux 25/03/2008, 00h16   #4
Javi
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Running script after logging out of SSH

On 24 mar, 22:14, laredotornado <laredotorn...@zipmail.com> wrote:
> Hi,
>
> I'm using Fedora Core Linux 6 and currently using zsh, but I can
> change shells. What I'm wondering is how I would execute a script
> after I have logged out via SSH. My normal way of working is to use
> Putty on my Windows XP machine to SSH in to my Linux box. When I
> click "exit" from Putty when logged in as user "me", I would like to
> run a script that backs up certain files.
>
> Thanks, - Dave


You could use .bash_logout (or zsh equivalent ?) feature. I'm not sure
about its use on .bash_logout, but 'nohup' command could tu run
your commands.
  Réponse avec citation
Vieux 26/03/2008, 21h00   #5
laredotornado
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Running script after logging out of SSH

On Mar 24, 6:16pm, Luuk <L...@invalid.lan> wrote:
> laredotornadoschreef:
>
> > Hi,

>
> > I'm using Fedora Core Linux 6 and currently using zsh, but I can
> > change shells. What I'm wondering is how I would execute a script
> > after I have logged out via SSH. My normal way of working is to use
> > Putty on my Windows XP machine to SSH in to my Linux box. When I
> > click "exit" from Putty when logged in as user "me", I would like to
> > run a script that backs up certain files.

>
> > Thanks, - Dave

>
> type:
> $ man zsh
>
> and search for 'logout'
> (by typeing '/logout'...)
> you'll find the info there
>
> --
> Luuk


So the file is ~/.zlogout. Thanks to the group for that one. Here's
a follow up. My .zlogout file consists of

nohup sh /opt/scripts/backup_web.sh

As I said, I'm logged in through PuTTy on Windows XP, but when I exit,
like below, the window doesn't close, instead it just hangs on the
last line:

[me@mymachine]/opt/scripts% exit
nohup: appending output to `/home/me/nohup.out'

Is there a way to have the process run in the background AND logout so
that the PuTTY window closes? - Dave
  Réponse avec citation
Vieux 26/03/2008, 21h45   #6
Scott McMillan
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Running script after logging out of SSH

On Wed, 26 Mar 2008 13:00:42 -0700 (PDT), laredotornado
<laredotornado@zipmail.com> wrote:

>On Mar 24, 6:16pm, Luuk <L...@invalid.lan> wrote:
>> laredotornadoschreef:
>>
>> > Hi,

>>
>> > I'm using Fedora Core Linux 6 and currently using zsh, but I can
>> > change shells. What I'm wondering is how I would execute a script
>> > after I have logged out via SSH. My normal way of working is to use
>> > Putty on my Windows XP machine to SSH in to my Linux box. When I
>> > click "exit" from Putty when logged in as user "me", I would like to
>> > run a script that backs up certain files.

>>
>> > Thanks, - Dave

>>
>> type:
>> $ man zsh
>>
>> and search for 'logout'
>> (by typeing '/logout'...)
>> you'll find the info there
>>
>> --
>> Luuk

>
>So the file is ~/.zlogout. Thanks to the group for that one. Here's
>a follow up. My .zlogout file consists of
>
>nohup sh /opt/scripts/backup_web.sh
>
>As I said, I'm logged in through PuTTy on Windows XP, but when I exit,
>like below, the window doesn't close, instead it just hangs on the
>last line:
>
>[me@mymachine]/opt/scripts% exit
>nohup: appending output to `/home/me/nohup.out'
>
>Is there a way to have the process run in the background AND logout so
>that the PuTTY window closes? - Dave



Append " &" to that line:

nohup sh /opt/scripts/backup_web.sh &


Scott McMillan
  Réponse avec citation
Vieux 26/03/2008, 23h45   #7
Andrew Smallshaw
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Running script after logging out of SSH

On 2008-03-26, laredotornado <laredotornado@zipmail.com> wrote:
> On Mar 24, 6:16pm, Luuk <L...@invalid.lan> wrote:
>>
>> type:
>> $ man zsh
>>
>> and search for 'logout'
>> (by typeing '/logout'...)
>> you'll find the info there
>>
>> --
>> Luuk

>
> So the file is ~/.zlogout. Thanks to the group for that one. Here's
> a follow up. My .zlogout file consists of
>
> nohup sh /opt/scripts/backup_web.sh
>
> As I said, I'm logged in through PuTTy on Windows XP, but when I exit,
> like below, the window doesn't close, instead it just hangs on the
> last line:
>
> [me@mymachine]/opt/scripts% exit
> nohup: appending output to `/home/me/nohup.out'


You need an ampersand after the nohup command:

nohup sh /opt/scripts/backup_web.sh &

I missed the beginning of this thread so I don't know if you were
using zsh anyway. You can do the same thing with any sh compatible
shell via the trap command in the login shell (e.g. via .profile):

trap "/command/to/execute -options" 0


--
Andrew Smallshaw
andrews@sdf.lonestar.org
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 22h24.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,13656 seconds with 15 queries