LinuxQuestions.org
Visit the LQ Articles and Editorials section
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: CentOS 6 (pre-systemd)
Posts: 2,173

Rep: Reputation: 554Reputation: 554Reputation: 554Reputation: 554Reputation: 554Reputation: 554
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: Centos 6.6, Centos 5.10
Posts: 16,462

Rep: Reputation: 2119Reputation: 2119Reputation: 2119Reputation: 2119Reputation: 2119Reputation: 2119Reputation: 2119Reputation: 2119Reputation: 2119Reputation: 2119Reputation: 2119
'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 Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 6,364

Rep: Reputation: 1721Reputation: 1721Reputation: 1721Reputation: 1721Reputation: 1721Reputation: 1721Reputation: 1721Reputation: 1721Reputation: 1721Reputation: 1721Reputation: 1721
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


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
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


All times are GMT -5. The time now is 04:58 AM.

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