LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-30-2014, 01:50 PM   #1
Noazet
LQ Newbie
 
Registered: Mar 2014
Posts: 3

Rep: Reputation: Disabled
Question Run bash script automatically after root logs in


Guys I am new to Linux .. I am using redhat ... I did a script which check if the one logging in is the root or another one but the problem is that every time I want the bash script to run I should make right click and open terminal and type sh script.sh so I want the script to run automatic after logging in so what steps or commands should I write ???
 
Old 03-30-2014, 02:31 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
Please don't post twice.
 
Old 03-30-2014, 02:36 PM   #3
mustafa_ibrahim
LQ Newbie
 
Registered: Mar 2014
Posts: 11

Rep: Reputation: Disabled
you could use a cronjob..have a little google, there are lots of good examples and explanations out there..
 
Old 03-30-2014, 02:37 PM   #4
mustafa_ibrahim
LQ Newbie
 
Registered: Mar 2014
Posts: 11

Rep: Reputation: Disabled
http://www.thegeekstuff.com/2009/06/...ntab-examples/

here's 1 that gives you a few examples....
 
Old 03-30-2014, 02:48 PM   #5
Noazet
LQ Newbie
 
Registered: Mar 2014
Posts: 3

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by mustafa_ibrahim View Post
http://www.thegeekstuff.com/2009/06/...ntab-examples/

here's 1 that gives you a few examples....
Is there a way to edit in bashrc ??
 
Old 03-30-2014, 03:23 PM   #6
mustafa_ibrahim
LQ Newbie
 
Registered: Mar 2014
Posts: 11

Rep: Reputation: Disabled
yea you edit it with "crontab -e" as described in that article..if you want it at boot up you use "@reboot" and then you write the path to your script

if the script needs root permission you use a "sudo crontab -e"..
 
Old 04-01-2014, 05:03 AM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
'crontab -e' edits the user's crontab file : usually /var/spool/cron/<user> .
For bashrc, use eg vim.
 
Old 04-01-2014, 06:42 AM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
Quote:
Originally Posted by Noazet View Post
Is there a way to edit in bashrc ??
root can edit it with any text editor (for example: vi)
 
  


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
Run bash script automatically after the root log in Noazet Linux - Newbie 1 03-30-2014 06:23 PM
[SOLVED] bash; automatically run user script after startx has completed porphyry5 Programming 5 03-05-2013 12:55 PM
Run shell script as root automatically elempoimen Linux - Software 8 06-20-2010 01:24 AM
Granting root permissions to a bash script than can be run by a user? SirTristan Linux - Newbie 4 06-14-2008 10:29 PM
Getting bash script files to run as root user helptonewbie Programming 5 04-13-2007 09:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:22 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