• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Startup Scripts in Linux

 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

How to set up some start up scripts in Linux. I want to start some of my applications during OS start up. How to do this?
 
Joe Ess
Bartender
Posts: 9313
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are many mechanisms for accomplishing what you want. The easiest thing to do would be to check the FAQ for the flavor you have to see what the preferred method is for that distribution.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In most cases, what you'll want is an "init script". Init scripts are started and stopped by the runlevel manager, and typically a Linux server will start up to either runlevel 3 (non-GUI, networked) or runlevel 5 (GUI). There's some interesting magic that gets applied to ensure that resource are running (or not) at a given runlevel and in the proper sequence so that pre-requisite resources are there (or not) when needed. It's not perfect, so Sun recently (Solaris 10) added an more sophisticated runlevel manager (not available to Linux, alas). And there's supposed to be improvements in the works for Linux as well, but they're slow in coming.

A typical runlevel script is headed up with some "magic comments" that the system can use to manage the script with. Red Hat/Fedora have one set, SuSe have another (with some overlap), and I forget the details from the Debian/Knoppix/Ubuntu platform. The master copies of the init scripts are stored in /etc/init.d, with aliases made to them to provide the actual runlevel control (this is typically done via the "chkconfig" utility). init scripts are expected to setup an environment (possibly starting a daemon) and returning. Don't make a long-running script, or it will hang the runlevel switching process, including the other apps.

The best thing to do is look at the scripts in your system's /etc/init.d directory. Some are pretty simple. Some are pretty nasty. But they'll help you get what you want.

Java apps are especially problematic, since the executable program's name is typically "java", rather than a unique appname, but there are tricks that can be done to make them reasonably co-operative.
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jothi Shankar Kumar wrote:Guys,

How to set up some start up scripts in Linux. I want to start some of my applications during OS start up. How to do this?


Shall your scripts start some graphic application, or will they stay in the background?

Do they have to be started with admin privileges?

Do they need to run before a user is loged in, or may they start when a user starts a session?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic