DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 8th November 2010
guitarscn guitarscn is offline
Package Pilot
 
Join Date: Oct 2008
Posts: 166
Default Cannot start program in rc.local

Code:
# cat /etc/rc.local                                        
#       $OpenBSD: rc.local,v 1.39 2006/07/28 20:19:46 sturm Exp $

# Site-specific startup actions, daemons, and other things which
# can be done AFTER your system goes into securemode.  For actions
# which should be done BEFORE your system has gone into securemode
# please see /etc/rc.securelevel.

echo -n 'starting local daemons:'

# Add your local startup actions here.

if [ -x /usr/local/bin/socks.sh ]; then
            echo -n ' socks';
            /usr/local/bin/socks.sh
fi

if [ -x /usr/local/bin/dns.py ]; then
            echo -n ' dns';
            /usr/local/bin/dns.py >/dev/null 2>&1 &
fi

echo '.'
I cannot seem to start dns.py. Whenever I boot up my machine and check ps aux, it's not on there. I can run it from the command line just fine with "/usr/local/bin/dns.py >/dev/null 2>&1 &" (as root or sudo).

Last edited by guitarscn; 8th November 2010 at 02:01 AM.
Reply With Quote
  #2   (View Single Post)  
Old 8th November 2010
ocicat ocicat is offline
Administrator
 
Join Date: Apr 2008
Posts: 3,318
Default

Quote:
Originally Posted by guitarscn View Post
I cannot seem to start dns.py.
Let's experiment.

Beginning with the following:
Code:
#!/usr/local/bin/python

import time

print 'start : %s' % time.ctime()
time.sleep(10)
print 'end : %s' % time.ctime()
Assuming this is saved as sleep.py:
  • Ensure the file is executable:
    Code:
    $ ls -l sleep.py
    -rwxr-xr-x  1 me  users  119 Nov  7 18:41 sleep.py
  • Ensure the availability of the interpreter:
    Code:
    $ which python
    /usr/local/bin/python
    By default, the Python binary is installed with the version number. Unless a symbolic link has been created with ln(1), this may be a reason why the script cannot be executed.
  • Likewise, the path returned by which(1) must match the first line of the script unless the script is run as a command-line argument.
  • Execute the script above, & while it running, check ps(1).
    Code:
     $ ps aux | grep python 
    me      32464  4.1  0.2  1948  3968 p0  S+     6:58PM    0:00.08 /usr/local/bin/python ./sleep.py (python2.6)
    me      24570  0.0  0.0   472     4 p1  R+     6:58PM    0:00.00 grep python (ksh)
    $
  • Quote:
    Whenever I boot up my machine and check ps aux, it's not on there.
    Two questions:
    • Do you see "dns" echoed during boot?
      Code:
      if [ -x /usr/local/bin/dns.py ]; then
                  echo -n ' dns';
                  /usr/local/bin/dns.py >/dev/null 2>&1 &
      fi
      If not, dns.py is not found on this path or it is not executable.

      You can also test the above code independently of rc.local (complete with enclosing if-statement...).
    • How long does dns.py take to execute?
    • Because this script is being started automatically, you will want to change ownership to root.
Beyond this, you need to provide more details.

I also invite you to review the following:

http://www.daemonforums.org/showthread.php?t=596
Reply With Quote
  #3   (View Single Post)  
Old 8th November 2010
guitarscn guitarscn is offline
Package Pilot
 
Join Date: Oct 2008
Posts: 166
Default

Thanks, I had solved this yesterday on my own with several reboots but forgot to report back here. I had to put in the full path to Python (/usr/local/bin/python) followed by the script. Now it works fine
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
mysql won't run via rc.local benben159 OpenBSD Packages and Ports 3 8th August 2010 02:41 PM
log from rc.conf.local and rc.local sdesilet OpenBSD General 1 21st January 2010 02:37 AM
Local transfer is slow. maurobottone OpenBSD General 1 10th January 2009 02:12 PM
local dns (dnsmasq) bsdperson FreeBSD Ports and Packages 3 3rd September 2008 06:48 AM
proxy : replace gif with local gif milo974 OpenBSD General 4 17th July 2008 06:45 AM


All times are GMT. The time now is 02:11 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick