I have nginx and postgresql daemons installed. How can make them start automatically every time server is started?

I think to add

sudo service nginx start
sudo service postgresql start

to ~/.profile but not sure if it's a good practice.


First list the service using chkconfig command

[root@localhost ~]# chkconfig --list | grep -i postgresql
postgresql-8.4  0:off   1:off   2:on    3:on    4:on    5:off   6:off

Suppose if you want to run postgresql automatically every time server is started

Then Try this command

[root@localhost ~]# chkconfig --level 5 postgresql-8.4 on

Here --level means in which runlevel you want to start(on) the service in my case it's runlevel 5

Do the same for other service also

After doing this servcie will automatically start when system boots.


Try doing this :

cd /etc/init
vim nginx*.conf

See mans :

init (5)             - Upstart init daemon job configuration
init (7)             - Upstart process management daemon
init (8)             - Upstart process management daemon

I mean :

man 5 init; man 7 init; man 8 init

found with :

man -k init | grep -o '^init (\w)'
init (5)
init (7)
init (8)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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