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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
03-30-2014, 01:50 PM
|
#1
|
LQ Newbie
Registered: Mar 2014
Posts: 3
Rep: 
|
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 ???
|
|
|
03-30-2014, 02:31 PM
|
#2
|
Senior Member
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,297
|
Please don't post twice.
|
|
|
03-30-2014, 02:36 PM
|
#3
|
LQ Newbie
Registered: Mar 2014
Posts: 11
Rep: 
|
you could use a cronjob..have a little google, there are lots of good examples and explanations out there..
|
|
|
03-30-2014, 02:37 PM
|
#4
|
LQ Newbie
Registered: Mar 2014
Posts: 11
Rep: 
|
|
|
|
03-30-2014, 02:48 PM
|
#5
|
LQ Newbie
Registered: Mar 2014
Posts: 3
Original Poster
Rep: 
|
Quote:
Originally Posted by mustafa_ibrahim
|
Is there a way to edit in bashrc ??
|
|
|
03-30-2014, 03:23 PM
|
#6
|
LQ Newbie
Registered: Mar 2014
Posts: 11
Rep: 
|
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"..
|
|
|
04-01-2014, 05:03 AM
|
#7
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,430
|
'crontab -e' edits the user's crontab file : usually /var/spool/cron/<user> .
For bashrc, use eg vim.
|
|
|
04-01-2014, 06:42 AM
|
#8
|
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 24,011
|
Quote:
Originally Posted by Noazet
Is there a way to edit in bashrc ??
|
root can edit it with any text editor (for example: vi)
|
|
|
All times are GMT -5. The time now is 08:19 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|