Go Premium for a chance to win a PS4. Enter to Win


Background Programme in Linux

Posted on 2004-04-05
Medium Priority
Last Modified: 2010-04-21
I've written a SMS system in java. I need that system to be executed in the linux background (as services in win2k). How can I do it ?. I use a *.jar file in my system.
Question by:bugbase
  • 2
  • 2
  • 2
LVL 45

Expert Comment

ID: 10763325
services in linux are run a daemon processes

check this link

Expert Comment

ID: 10794184
There are 3 ways of doing it :
1. Make it run as a daemon.
2. Try the conventional & to push the process to the background(typeing 'jar <filename>.jar &' should do the trick.
3. Put the process(if need be, using an intermediate shell script containig the line : 'jar <filename>.jar ') in the startup list.

If these are not wht you want, please specify if you want the process to get started during startup.

Author Comment

ID: 10819741
This is the thing I'm a new bie to Linux so that I dont know how to Shell program. I need a program kind of thing to work that out.

Lets say I have mySys.jar, Can u show how to do it step by step......
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.


Author Comment

ID: 10819763
Yes I want to start the process @ start up too. I use a configuration file too to get environment from the system and in my jar file I use a class named Service to the start the system.
LVL 45

Expert Comment

ID: 10821029
write the command that needs to be run into a script and put the script at oneof /etc/rc* dir
replace * with appropriate run level

read this link and man page for init for more information
man init

Accepted Solution

ray_pro2 earned 1000 total points
ID: 10850890
Let us do it a step at a time.....

1. How to write a shell program ?
   Very simple.

   step 1 : open a plain text file, using your favourite text editor. I will assume the use of vi editor.  Let the name of your first shell program be script1. Then you can open it using vi by typing the command
                        $ vi script1 [enter]

   step 2 : The shell has an embedded programming language. It understands all the linux commands available in your system, combined with some programming languagfe like constructs.
Let us write a simple script, that complies and runs a jar program, if there are no errors during compilation. Of course the source filename has to be supplied as the first argument. Type these lines of code in the file script1:

             #All comment line start with #.
             #This line executes the command jar, with the first argument to the shell script as
              #its source.
             jar $1 &

    step 3 : save this file (here press :Esc, then :, then wq and then Enter). Give execute permission to this script by typing the command:

               $ chmod 755 script1

    step 4 : Now your shell program is ready to run. If you want to complie and run the program mySys.jar, writting this line should do (provided, both mySys.jar and script1 are in the current directory):

                $ ./script1 mySys.jar

The '&' in the script puts the process in the background. The philosophy of shell scripting/programming is very straightforward. A linux shell executs commands that you type into a terminal. Internally, linux like any other UNIX system treats your terminal as a file, in which the commands are present in the form of character strings. The speciality of the linux (or any UNIX) shell is that, it can not only execute commands from the terminal file, but also from any other file(like script1 above). This is conceptually very similar to the batch file of MS-DOS. But a shell script/program can do much more than just executing commands in a batch. It can also provide programming constructs like if, if-then-else, case-construce, for loop, while loop, until loop, functions and much more.

2.  How to put the program in startup?

    Since you have not been specific, I assume Red Hat Linux 8.0 or higher running in Gnome Desktop mode. Follow the steps to put your shell script in start-up:

    1. Double click 'Start-Here' icon on your desktop. A file manager window will open up.
    2. Double click the 'Preferences' icon.
    3. Double click the 'Extras' icon.
    4. Double click the 'Sessions' icon.
    5. Select the 'startup programs' tab.
    6. Click the 'add' button.
    7. specify the path of your script in the space provided and click 'OK'.

Next time you boot up, you will find your program getting started up at Startup. Make sure that you have given your script execute permissions before you put it at startup.

If you are still not clear about the 'Shell programming' thing, next time be more specific about your intensions.

Featured Post

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question