Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
Does the script run OK if you run it manually as root? –  onik Feb 21 '12 at 4:50
    
It works fine if i run the following command /etc/init.d/openerp-server –  Jibin Feb 21 '12 at 4: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 4: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 5:14
add comment

3 Answers

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.

share|improve this answer
add comment

Use this commands:

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


sudo update-rc.d openerp-server defaults
share|improve this answer
    
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
add comment

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)

share|improve this answer
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.