• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

Startup Scripts in Linux

 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 9625
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Saloon Keeper
Posts: 23544
161
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
reply
    Bookmark Topic Watch Topic
  • New Topic