Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm facing an issue with a python file that I'd like to start as a service. I named my service ocrserver and the script I want to start is in /home/administrator/ocr/ocrserver/init.py with some parameters added like --address --port etc... After reading the documentation from the FreeBSD site

I wrote the following script:


# $FreeBSD$
# PROVIDE: ocrserver 
# KEYWORD: shutdown

# add the following line to /etc/rc.conf to enable the ocrserver:
# ocrserver_enable="YES"

. /etc/rc.subr


# default values
: ${ocrserver_enable="NO"}






# -p : daemon handler pidfile
# -f : redirect stdout and stderr to /dev/null
# -c : change working dir to root
command_args="-p ${pidfile} -f -c /home/administrator/ocr/ocrserver/__init__.py \
--address ${address} --http-port ${http_port} --log-level ${log_level} \
--pyproxy-port ${pyproxy_port}"


load_rc_config $name
run_rc_command "$1"

Then I added one line setting up the corresponding rcvar to YES in the /etc/rc.conf file. and I launched it:

sudo service ocrserver start where I get the message "Starting ocrserver". and after entering a sudo service ocrserver status, I can see that the service is not running. I also ran a pgrep -l python3.3 command to see if any python3 process was running but no result

I precise that I did a chmod 755 on the file to make it readable and executable by all the users.

Has anyone some experience with this kind of thing?

Thanks for your answers.

share|improve this question
running __init__.py as a script is probably an error. You could put the main() part from __init__.py into __main__.py and try to run it as python3.3 -mocrserver (/home/administrator/ocr/ should be in Python path in this case (python3.3 -c 'import sys; print("\n".join(sys.path))')). – J.F. Sebastian Nov 2 '13 at 6:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.