Start a service manager process automatically on startup


 
Thread Tools Search this Thread
Operating Systems Linux Red Hat Start a service manager process automatically on startup
# 1  
Old 02-27-2014
Computer Start a service manager process automatically on startup

Hello,

I am in the process of learning Linux OS.

How do I run the below lines of code automatically as root on server startup.


cd /opt/program_folder/ServiceManager/bin
nohup ./servce_manager DEV &


Currently, as soon as the server is up and running I log in as root (as this program needs to be run as root) and run the above lines of code.

How do I set up this code in rc.d to run automatically?
When the server goes down I do not worry as it does not need to be shutdown gracefully. The only way right now is to kill the process, if there is a need to shutdown the service_manager.

Please help me out.

Thanks,
Ram.
# 2  
Old 02-27-2014
There are lots of ways to do it.

One option might be to put a line in root's crontab, which you edit via crontab -e:

Code:
@reboot cd /opt/program_folder/ServiceManager/bin ; nohup ./servce_manager DEV &

This User Gave Thanks to Corona688 For This Post:
# 3  
Old 02-27-2014
Quote:
Originally Posted by Corona688
There are lots of ways to do it.

One option might be to put a line in root's crontab, which you edit via crontab -e:

Code:
@reboot cd /opt/program_folder/ServiceManager/bin ; nohup ./servce_manager DEV &

Tested the entry in crontab and worked like a charm. Thank You very much.

I have another question. I have a script (ksh script) that starts an application listener.
It is owned by a user scott (command for example: start_listener.ksh -a start ).
This also needs to start at the server start up as scott.

Could you kindly guide me?

Thanks,
Ram.
# 4  
Old 02-27-2014
Login to scott and add it to his crontab. You may need to add him to the cron group like usermod -a -G cron scott before crontab -e will work.

You may want to nohup command & that one as well.
This User Gave Thanks to Corona688 For This Post:
# 5  
Old 02-27-2014
I finally figured the answer to my question. Used the same technique of crontab suggested by you. I did as below:
Code:
su - scott -c 'start_listener.ksh -a start'

I put the above code in a strt_lsnr.sh
executed the script using your technique using an entry in crontab.

Thanks You very much for guiding me.

Thanks,
Ram.
# 6  
Old 03-17-2014
Quote:
Originally Posted by Corona688
Login to scott and add it to his crontab. You may need to add him to the cron group like usermod -a -G cron scott before crontab -e will work.

You may want to nohup command & that one as well.

Hi Corona wont just running the below command as root add the cron job to that user specified ?
Code:
crontab -u scot -e

Why need to log into the user ? Just curious because it worked for me many times before.

Thanks,
# 7  
Old 03-17-2014
Quote:
Originally Posted by Sasi_Ryu
Hi Corona wont just running the below command as root add the cron job to that user specified ?
Code:
crontab -u scot -e

Why need to log into the user ? Just curious because it worked for me many times before.

Thanks,
You don't need root access, just scot access, to set up scot's crontab by logging in as scot.

It also makes it harder to mess up anything else by accident, since you'll have access to only scot's crontab etc.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Starting a service at startup.

Hi guys I want to start a service and a script SiteMonitor.sh at startup. To start with i have modified /etc/rc.local file. Here is the content of my /etc/rc.local file. #!/bin/sh # # This script will be executed *after* all the other init scripts. # You can put your own... (3 Replies)
Discussion started by: pinga123
3 Replies

2. Shell Programming and Scripting

Script - How to automatically start another process when the previous process ends?

Hi all, I'm doing automation task for my team and I just started to learn unix scripting so please shed some light on how to do this: 1) I have 2 sets of datafiles - datafile A and B. These datafiles must be loaded subsequently and cannot be loaded concurrently. 2) So I loaded datafile A... (10 Replies)
Discussion started by: luna_soleil
10 Replies

3. Solaris

StartUP file to start a service

Hi guys: i have a Solaris 10 development server and a Solaris 9 production server. The entire task must be done in the dev. server. When it's done and all the testing is OK, the script or files are transfer to prod. Server. All right. Now I have to figure out a way to put a script to initiate... (2 Replies)
Discussion started by: bmathiasf
2 Replies

4. AIX

service/process management -autostart at startup

Hi, I want to modify some of the services/processes (related to the oracle database) to start automatically at the startup of the server. which commands may help me? which commands do I need to use? my server configuration is, in brief: hardware:IBM P550 / OS : AIX 5300 thanks,... (1 Reply)
Discussion started by: talipk
1 Replies

5. AIX

Creating startup service for JBoss

Hello Friends, Does anyone know how to create a startup script for Jboss on IBM AIX 5.3? Please help me, I'd be highly grateful to you... Thanks & Regards, Vinit (0 Replies)
Discussion started by: vpatil6688
0 Replies

6. Shell Programming and Scripting

How can I make a program start up automatically after the computer restart/startup?

hi all How can I make a program start up automatically after the computer restart/startup in fedora? something like: ... Establish a shell then run some of command code. Thanks for Help!! (1 Reply)
Discussion started by: munna_dude
1 Replies

7. Solaris

stop a process to start at system startup

Hi all! I'm running Solaris 10 and have a question about how i can stop a certain program to start at system startup,for example, as it is now sendmail is starting but i don't need sendmail,on the other hand so would i be very glad to get cups up and running at startup, anyone who can explain where... (3 Replies)
Discussion started by: larsgk
3 Replies

8. UNIX for Advanced & Expert Users

AIX 5.3: Start Service on System startup

Hi, I'm new to AIX, and have to make some services start at system startup. The IBM-Redbook says I have to edit /etc/inittab. As a long time (Debian)-Linux Admin I'm a bit confused. Is there something like /etc/init.d/$SERVICE in AIX? Greetings, Dennis (1 Reply)
Discussion started by: dennis.kuehl
1 Replies

9. UNIX for Dummies Questions & Answers

How can I add my own service when system startup?

Hi All, My OS is redhat 7.1. How can I start my own service (e.g. simple scripts) when the system is started? I found something like /etc/rc.d, /etc/rc.init ... But I have no idea on them, have anyone can help me? regards wilson (6 Replies)
Discussion started by: wilsonchan1000
6 Replies
Login or Register to Ask a Question