Starting a Process Automatically on Reboot

Hi Linux friends,

All I want to do is to have a process start automatically when the server reboots.  Nothing fancy.  Right now, I manually start the process like this:

[root@localhost root]# cd /programfiles/tibco/tra/domain/TuxDomain/
[root@localhost root]# ./hawkagent_TuxDomain

I also have another process where I have to send it a parameter:

[root@localhost root]# cd /programfiles/tibco/ems/bin
[root@localhost root]# ./tibemsd -config FTBackup/tibemsd.conf

I know I have to do something with /etc/init.d, but I'm not sure exactly what.  

Thank you so much,


Jazon
LVL 3
piratepatrolAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tim_UtschigCommented:
If you're running a Red Hat-ish distribution, you can put the commands in /etc/rc.d/rc.local
piratepatrolAuthor Commented:
I have Fedora Core 2.

The tricky part is that one of the processes is the type that if you start it in the console, it runs, but then stops if you close the console.  Given that, can I still do the following:

cd /programfiles/tibco/tra/domain/TuxDomain/
./hawkagent_TuxDomain

cd /programfiles/tibco/ems/bin
./tibemsd -config FTBackup/tibemsd.conf

The first one is the one that stops when I close the console.

Thanks again.
Tim_UtschigCommented:
> The first one is the one that stops when I close the console.

Try prepending "nohup " and appending "< /dev/null > /dev/null 2>&1" to the command, e.g:

    nohup ./hawkagent_TuxDomain < /dev/null > /dev/null 2>&1
Expert Spotlight: Joe Anderson (DatabaseMX)

We’ve posted a new Expert Spotlight!  Joe Anderson (DatabaseMX) has been on Experts Exchange since 2006. Learn more about this database architect, guitar aficionado, and Microsoft MVP.

Tim_UtschigCommented:
An alternative to rc.local is a crontab entry using @reboot.  For example, create a file /root/start-stuff that contains:

#!/bin/sh
cd /programfiles/tibco/tra/domain/TuxDomain/
nohup ./hawkagent_TuxDomain < /dev/null > /dev/null 2>&1
cd /programfiles/tibco/ems/bin
./tibemsd -config FTBackup/tibemsd.conf

Then run:

    chmod +x /root/start-stuff

And create a crontab that runs it at reboot:

    echo "@reboot /root/start-stuff" | crontab -

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
piratepatrolAuthor Commented:
I really appreciate this, Tim.

This is what I'm putting into the rc.local file...


# Start TIBCO Hawk Agent.
cd /programfiles/tibco/tra/domain/TuxDomain/hawkagent_TuxDomain
nohup ./hawkagent_TuxDomain < /dev/null > /dev/null 2>&1

# Start the primary and backup TIBCO EMS instances.
cd /programfiles/tibco/ems/bin
nohup ./tibemsd < /dev/null > /dev/null 2>&1
nohup ./tibemsd -config FTBackup/tibemsd.conf < /dev/null > /dev/null 2>&1

# Start the TIBCO Administrator.
cd /programfiles/tibco/administrator/domain/TuxDomain/bin
nohup ./tibcoadmin_TuxDomain < /dev/null > /dev/null 2>&1

Do you see any problems with this setup?
Tim_UtschigCommented:
> Do you see any problems with this setup?

No.
However I'm not familiar with the particular programs you are running.
piratepatrolAuthor Commented:
I'm going to reboot my Linux server and hope for the best!  :)

I'm the TIBCO administrator for my company, and TIBCO is a huge software package used for systems integration.

We use all Microsoft at work, but I'm just playing with it in my Linux server at home.  I'll let you know if all is well after the reboot.  Your help is deeply appreciated.
piratepatrolAuthor Commented:
Hi Tim - here's the error I get . . . .

/etc/rc3.d/S99local: line 10: cd: /programfiles/tibco/tra/domain/TuxDomain/hawkagent_TuxDomain: No such file or directory

I don't know why it's saying this.  Here's proof I didn't have a typo . . . :)

[root@localhost TuxDomain]# cd /programfiles/tibco/tra/domain/TuxDomain
[root@localhost TuxDomain]# ls
AdministrationDomain.properties  hawkagent_TuxDomain      plugin
application                      hawkagent_TuxDomain.tra  rulebase
AuthorizationDomain.properties   inithawk                 startup
autoconfig                       local.properties
hawkagent.cfg                    logs
[root@localhost TuxDomain]#

Any thoughts?
piratepatrolAuthor Commented:
Oh gosh, I'm stupid.  Hold on...
Tim_UtschigCommented:
Heh, sorry I didn't catch that.
piratepatrolAuthor Commented:
Okay, I changed

cd /programfiles/tibco/tra/domain/TuxDomain/hawkagent_TuxDomain

to

cd /programfiles/tibco/tra/domain/TuxDomain

Heheh!  My bad!

I rebooted, and right now it's hung on the following . . .

Starting system message bus:                      [  OK  ]

And that's it.  The cursor is blinking underneath, and it's not going to the login screen.  I used PuTTY to connect to the Linux server from my Windows XP laptop, issued ps -ef , and I notice that only the Hawk Agent is started (this is the first process started from rc.local).  All the others I specified in the rc.local file did not start.  Weird.

Any thoughts on this issue?  Thanks again.
pjedmondCommented:
Yep - Make the process detach and return immediately - add a & to the end of command.

e.g:

wget http://www.mydomain.com/bigfile.tar.gz

will wait until the wget command has finished before continuing, whilst

wget http://www.mydomain.com/bigfile.tar.gz &

will return immediately and carry on the script (although any output will still get printed to the terminal in question...but that can be redirected as you appear to have done)

HTH:)
Tim_UtschigCommented:
Yes, as pjedmond said, just add an ampersand to the end of commands that don't background themselves.
piratepatrolAuthor Commented:
Worked like a charm!  You guys are awesome.  Thank you so much.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Distributions

From novice to tech pro — start learning today.