0

I have a script openerp-server.py in ~/openerp/stable6/server/bin/.I want it to be run at startup.(As a service or not - I don't know the difference)

These are the steps I followed

1 Created a script 'openerp-server' with the following lines in /etc/init.d/

#!/bin/sh
cd ~/openerp/stable6/server/bin/
exec /usr/bin/python ./openerp-server.py $@

2 Made the script executable by using the following command

sudo chmod +x /etc/init.d/openerp-server

3 Made the link run on startup by using the following command

sudo update-rc.d openerp-server 

I checked using sysv-rc-conf.And openerp-server was selected for run level 2,3,4,5.

Now after restarting I checked if the openerp-server.py is running, it was not running.

Please help.

Jibin
  • 111
  • 1
  • 4
  • Does the script run OK if you run it manually as root? – onik Feb 21 '12 at 04:50
  • It works fine if i run the following command `/etc/init.d/openerp-server` – Jibin Feb 21 '12 at 04:54
  • Then it seems to be a problem in the order in which the startup scripts are run, e.g. your script runs before a dependency like networking. Just move it later in the startup like robbyt suggests. – onik Feb 21 '12 at 04:58
  • I did as robbyt said but still its not running at startup.Where is the log file in ubuntu to check errors ? – Jibin Feb 21 '12 at 05:14
  • can you tell output of "which bash" command? – TBI Infotech Jul 25 '14 at 05:58

3 Answers3

1

You can drop commands like this into /etc/rc.local and they will be executed as the last stage in the boot process.

This is a bit of a hack however, you should check out the upstart tutorial to write your own init script (service)

robbyt
  • 1,622
  • 3
  • 14
  • 26
1

Use this commands:

sudo chown root:root /etc/init.d/openerp-server


sudo update-rc.d openerp-server defaults
georgian
  • 11
  • 2
  • I tried.The second command gives `System start/stop links for /etc/init.d/openerp-server already exist`.I checked if the script is running by using `ps ax | grep openerp-server` it gave `1962 pts/0 S+ 0:00 grep --color=auto openerp-server`.The `openerp-server` was in red.What does this mean ? – Jibin Feb 21 '12 at 10:24
  • Try this: sudo update-rc.d openerp-server remove **and after** sudo update-rc.d openerp-server defaults – georgian Feb 21 '12 at 18:29
  • But if you want to run the script as a process why not run it with nohup ? Ex: nohup script_name & – georgian Feb 21 '12 at 18:36
0

In the startup script itself, get rid of the ~ and use full paths. Traditionally, /bin/sh is a very simple shell that does not perform tilde expansion.

200_success
  • 4,701
  • 1
  • 24
  • 42
sardean
  • 833
  • 3
  • 14
  • 34