Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
 
Reply to this topicStart new topic
> Making A Program Start When Linux Starts, autostart?
ryan0204
post Aug 27 2005, 09:00 PM
Post #1


Whats this Lie-nix Thing?
*

Group: Members
Posts: 3
Joined: 27-August 05
Member No.: 5,446



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)
Go to the top of the page
 
+Quote Post
Termina
post Aug 27 2005, 10:09 PM
Post #2


RMS is my Hero
******

Group: Support Specialist
Posts: 862
Joined: 18-February 04
From: Wisconsin
Member No.: 2,404



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


--------------------
*Points finger at the author above him* They're a witch! Burn them!
---
Vist my website!
Join me in IRC! Server: st0rage.org Channel: #UnhandledExceptions
Go to the top of the page
 
+Quote Post
ryan0204
post Aug 27 2005, 10:56 PM
Post #3


Whats this Lie-nix Thing?
*

Group: Members
Posts: 3
Joined: 27-August 05
Member No.: 5,446



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?
Go to the top of the page
 
+Quote Post
DS2K3
post Aug 28 2005, 06:57 AM
Post #4


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,284
Joined: 14-November 04
From: Southampton, Hampshire
Member No.: 4,165



Add "cd /home/username/bnbt/" and then "./bnbt" to the shell script


--------------------
Fixed your problem? Let us know!
richard@linuxhelp.net

www.Gathr.co.uk Online Event Management
Go to the top of the page
 
+Quote Post
ryan0204
post Aug 28 2005, 11:12 AM
Post #5


Whats this Lie-nix Thing?
*

Group: Members
Posts: 3
Joined: 27-August 05
Member No.: 5,446



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.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 12th December 2017 - 07:24 AM