LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 07-20-2007, 04:35 AM   #1
jpostma
Member
 
Registered: Jun 2003
Location: Alphen ad Rijn -- The Netherlands
Distribution: Fedora Core 2 - Slackware 12
Posts: 119

Rep: Reputation: 15
start script during log off


I have two harddisks. During log off I want to automatically copy some files from the first disk to the second for backup purposes. I have a script for this. I want that the script is executed during log off. Has someone an idea how I can do this?
 
Old 07-20-2007, 04:56 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

Assuming that you are talking about a user that logs out and that you use bash: Take a look at: ~/.bash_logout
Bash executes commands in this file after a user logs out.
Man bash (INVOCATION part) for details.

Hope this helps.
 
Old 07-20-2007, 05:18 AM   #3
synapse
Member
 
Registered: Jan 2004
Location: On Planet Earth.
Distribution: Slackware 12
Posts: 244

Rep: Reputation: 30
as root

add the command to copy
to the rc.shutdown script
 
Old 07-20-2007, 05:35 AM   #4
jpostma
Member
 
Registered: Jun 2003
Location: Alphen ad Rijn -- The Netherlands
Distribution: Fedora Core 2 - Slackware 12
Posts: 119

Original Poster
Rep: Reputation: 15
Thanks for your quick replies.
 
Old 07-20-2007, 05:37 AM   #5
titopoquito
Senior Member
 
Registered: Jul 2004
Location: Lower Rhine region, Germany
Distribution: Slackware64 14.2 and current, SlackwareARM current
Posts: 1,644

Rep: Reputation: 145Reputation: 145
Quote:
Originally Posted by synapse
as root

add the command to copy
to the rc.shutdown script
Are you sure it should not be named rc.local_shutdown? I never heard of your interesting tipp and did a quick grep on the rc.d scripts, but only rc.local_shutdown is shown ...
 
Old 07-20-2007, 05:40 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

rc.shutdown is BSD style init (will work for slackware). Fedora uses the SysV init, rc.shutdown is not a part of that.

Hope this clears things up.
 
Old 07-20-2007, 01:26 PM   #7
jpostma
Member
 
Registered: Jun 2003
Location: Alphen ad Rijn -- The Netherlands
Distribution: Fedora Core 2 - Slackware 12
Posts: 119

Original Poster
Rep: Reputation: 15
I have created a file .bash_logout in the root directory. I'm always logged on as root. The file isn't executed.
The contents is:

--------------
# .bash_logout
cp -r /root/* /usr/local/backup/root
clear
--------------

Any idea why it's not executed during logoff?
 
Old 07-20-2007, 04:43 PM   #8
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

Only thing I can come up with: .bash_logout is only executed if the shell started is a login shell. But you state that you are always logged on as root. Is this an automatically started X session (init 5) or a command line session (init 3)?
The latter (init 3) should normally be a login shell and all should be working. Some distro's don't give root a login shell when starting a X session, which could explain why .bash_logout is not executed.

Not much to go on, but I hope it helps.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Start a script after GDM autologin, don't quit when script finishes Plastech Linux - Newbie 2 05-29-2007 10:15 AM
Bash script for server log (namely var/log/messages) tenaciousbob Programming 17 05-24-2007 10:43 AM
How can I Start Linux without Log in? bbengg Linux - Newbie 2 05-21-2006 02:23 PM
How to start a Tcl/Tk script by simply invoking the script file itself ? cyu021 Programming 2 10-10-2004 11:00 AM
X Start Error log help brianh128 Linux - Newbie 8 10-17-2001 01:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 04:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration