Help - Search - Members - Calendar
Full Version: Making A Program Start When Linux Starts
Linuxhelp > Support > Technical Support
ryan0204
I have a bittorrent tracker setup on a server I use, the path to the executable is:
/home/username/bnbt/bnbt

Is there a simple way I can make this launch whenever the server starts up? I'm pretty new to linux so all the rc.local stuff seems really confusing to me. Any help would be appreciated.

(I'm using Fedora Core 3)
Termina
Please open up /etc/inittab, and you should see a line near the begining that says something similar to:

# The default runlevel.
id:2:initdefault:

The number between id and initdefault is your run level.

Now go to /etc/rc2.d (or whatever) and ls

You should see a fairly large number of scripts that all start with

S##
and
K##

S = Script is run at boot time as /etc/rc2.d/S##scriptname start
K = Script is run at boot time as /etc/rc.d/S##scriptname stop

The number is the order it is run (which shouldn't matter if you're running a standalone program that doesn't rely on any other programs being up at the time of it's execution)

Pick a number that doesn't exist, and make two of these scripts (below)

S##bnbt
K##bnbt

CODE
#!/bin/bash
#assumes that you want to run this program as a regular user (bnbt)
#you might have to fiddle with sudoers, but I doubt it
case "$1" in
       'start')
       sudo -u bnbt /home/username/bnbt/bnbt        
       echo "started"
              ;;
       'stop')
               killall -9 bnbt
               echo "stopped"
              ;;
       *)
               echo "usage: $0 {start|stop}"
              ;;
esac
ryan0204
Thanks a lot for the help, the startup part appears to be working, but now I'm getting errors with bnbt. The problem seems to be that when ever its launched from a directory other than the one its in I get errors. Say I'm in /tmp and type:
/home/username/bnbt/bnbnt

I'll get these errors:
[Sun Aug 28 01:02:00 2005] server error - unable to bind socket (error 98)
[Sun Aug 28 01:02:00 2005] warning - unable to open dstate.bnbt for reading
[Sun Aug 28 01:02:00 2005] warning - unable to open tags.bnbt for reading
[Sun Aug 28 01:02:00 2005] warning - unable to open users.bnbt for reading
[Sun Aug 28 01:02:00 2005] server - start
[Sun Aug 28 01:02:00 2005] server - exit

But if I'm in /home/username/bnbt and type ./bnbt it runs fine. Do you know of anyway to fix this within the startup file you made earlier?
DS2K3
Add "cd /home/username/bnbt/" and then "./bnbt" to the shell script
ryan0204
Thank you very much DS2K3, I was going crazy trying to figure out why it wasn't working. Can't believe all I needed to do was add the cd line.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2017 Invision Power Services, Inc.