LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-07-2009, 05:30 PM   #1
UpWorks
LQ Newbie
 
Registered: Dec 2009
Posts: 4

Rep: Reputation: 0
Bash Script Act on User Login


I am not familiar enough with the vernacular used for command line functions so please bare with me.

I need to have a bash script that fires when a user logs in; if the user == 'username' I need to do some maintenance on their directory under his username directory. Move files, zip etc.

What are the functions I would use?

Thank you in adavance.
 
Old 12-07-2009, 06:44 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally Posted by UpWorks View Post
I am not familiar enough with the vernacular used for command line functions so please bare with me.
I'd rather bear with you than bare. :}

Quote:
Originally Posted by UpWorks View Post
I need to have a bash script that fires when a user logs in; if the user == 'username' I need to do some maintenance on their directory under his username directory. Move files, zip etc.

What are the functions I would use?

Thank you in adavance.
Depends: what's the desired end result? Is there a
possibility that users will maliciously/non-intentionally
undo what you're trying to achieve?

The answer will depend on those things.

Trivially you could put things in the users
~/.bash_(login|profile) file ... you could put
them in /etc/profile or /etc/profile.d/myMaintenance.sh


Cheers,
Tink
 
Old 12-08-2009, 10:13 AM   #3
UpWorks
LQ Newbie
 
Registered: Dec 2009
Posts: 4

Original Poster
Rep: Reputation: 0
The 'user' is a Scheduled Task from a Windows Server that logs in every hour on the 15 mark and downloads forms that have been filled out by users in the company's web server (FreeBSD box).

When this task is complete, and I am now thinking the bash script should run when the fetch user logs out, as I need to perform some cleanup e.g. zip up all the files that were downloaded in a dir under his user directory and move them to a different directory under his user directory and then remove all the files from the first directory.

Reading what you wrote here:
Quote:
Trivially you could put things in the users
~/.bash_(login|profile) file ... you could put
them in /etc/profile or /etc/profile.d/myMaintenance.sh
Does that mean if I place my script in one of those directories it will fire when he logs in, how about when he logs out?

Thank you again for your time.
 
Old 12-08-2009, 10:32 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
If the fetch user logs in and uses bash and logs out then you could create ~fetch/.bash_logout and put you code in there. For more about bash login and logout files including .bash_logout see here. Maybe don't bother! Here's all it says: "When a login shell exits, Bash reads and executes commands from the file ~/.bash_logout, if it exists".
 
1 members found this post helpful.
Old 12-09-2009, 10:40 AM   #5
UpWorks
LQ Newbie
 
Registered: Dec 2009
Posts: 4

Original Poster
Rep: Reputation: 0
Thank you Tinkster and catkin -
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
super user privileges check for a normal user in bash script freeindy Programming 2 08-01-2008 06:08 AM
bash login script bunnyknight13 Linux - Newbie 4 09-10-2004 08:02 PM
bash login script seanatis Programming 6 09-06-2004 08:00 AM
Run script at login instead of bash uzi4u Linux - General 2 04-28-2004 02:31 PM
Trying to execute bash script upon login?? mr-d-2003 Linux - Newbie 4 10-30-2003 03:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:35 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration