LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE
User Name
Password
SUSE / openSUSE This Forum is for the discussion of Suse Linux.

Notices


Reply
  Search this Thread
Old 11-02-2005, 05:57 PM   #1
TKD
LQ Newbie
 
Registered: Nov 2005
Posts: 3

Rep: Reputation: 0
How to run a command automatically on start up


Sorry for (what seems to me as), a stupid question - I'm an IT pro but very new to Linux and fairly embarassed about it

I'm looking to run a command automatically at startup...

Specifically - ip route add 'ipaddress'/24 'gateway'

How could i do that?
In windows I would have just used the -p switch, is there an eqivalent in Linux?

Continuing from that - how would I launch an application immediately after log-in?
 
Old 11-02-2005, 06:11 PM   #2
IamSpOOk
LQ Newbie
 
Registered: Jul 2005
Posts: 15

Rep: Reputation: 1
You can make a permanent route by adding it to /etc/sysconfig/network/routes
 
Old 11-02-2005, 06:12 PM   #3
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
i'd assume there's a better solution to actually do what you want, but to do literally what you're asking, you'd add a line to /etc/rc.local

as for logging on, well that can be a little messy.. what does "log-in" mean? sounds daft, but every time you open a new terminal window in X, you're essentially logging on again... you can so this by adding commands to ~/.bashrc per user, but i don't think this is really what you're after
 
Old 11-02-2005, 06:12 PM   #4
IamSpOOk
LQ Newbie
 
Registered: Jul 2005
Posts: 15

Rep: Reputation: 1
If it's an X application, then you can add this to .xinitrc (or equiv for your particular display manager)
You can also add to the profile for your shell - typically ~/.bashrc
 
Old 11-02-2005, 06:24 PM   #5
scott_R
Member
 
Registered: Jul 2003
Location: Brighton, Michigan, USA
Distribution: Lots of distros in the past, now Linux Mint
Posts: 748

Rep: Reputation: 31
The ridiculously easy way is simply to take that line, preface it with a line above it invoking bash, then drop it into your start scripts directory (varies with distribution)

For instance, the script would be (and this most likely remains true on all distros):

#! /bin/bash
ip route add 'ipaddress'/24 'gateway'

create the file with your favorite editor, then navigate to /etc, and look for something along the lines of rc#.d (or a variation like rc.5, etc.), and copy the file there with the prefix S## (bigger numbers are better, as they start later, allowing more important processes to start first, though you might need a smaller number so it starts before a process that needs it up and running) (as the root user, obviously). use chmod to make sure it's readable/executable ('man chmod' on the command line can guide you), and reboot to test, or start the file manually (/etc/rc'directory'/name of your file.

Sounds complicated, but you can get the idea by looking at the relevant /etc/rc... files and directories and taking your cues from them. Don't be too worried about some of the items in the files themselves, as they are simply shell scripts to ensure that the programs don't start multiple copies or restart if they fail (you can add these things later, but for now they are redundant, as you can manually do the same if you must, and they don't typically fail in this manner).
 
Old 11-02-2005, 06:54 PM   #6
TKD
LQ Newbie
 
Registered: Nov 2005
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks guys - perfect. Seems that I learn at least 5 new useful procedures with every thread I read round here.

As for what I meant by 'log-in', sorry about that i'm still with 'windows speak' for the time being. I was refering to starting a session in X. Say if I logged in as 'TKD' i want gaim to auto-launch - whereas i'd want different apps to launch if i logged in as root.
Should I be looking at .xinitrc for this?
 
Old 11-03-2005, 05:41 AM   #7
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
well no you wouldn't, again depends what you're logging in to... gnome and KDE will autosave sessions is you want them to, so that's done at a totally hands-off patronizng gui level afaik, .xinitrc is only used when you load X from a console, not when you log into X through a grpahical login maanger. there is ~/.Xsession though.
 
  


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
How can a command/program be run automatically on boot? chuanweizuo Linux - Hardware 1 11-28-2005 11:36 AM
How to automatically run a command when you open a Konsole shazam75 Linux - Software 3 11-30-2004 05:02 AM
How can I run a command automatically at startup? luwigie Linux - General 8 08-26-2004 10:05 PM
How do I get Fedora to automatically run a command during startup? jlsain Linux - Software 2 03-23-2004 05:03 AM
start terminal & run command automatically peeples Linux - General 2 09-08-2003 03:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE

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