Linux – Start postfix automatically on linux

linuxpostfix

I have installed postfix on my server using this guide http://www.postfix.org/INSTALL.html#install

Basically creating my own package and installing. Now I want to start postfix automatically when the server reboots.

I have tried adding the symbolic link chkconfig --add postfix but I get this error: error reading information on service postfix: No such file or directory

I have postfix running just fine on the server expect for this. To start/stop postfix now I use

sudo postfix stop
sudo postfix start

Any ideas on how to get it to start on its own?

Best Answer

chkconfig --add postfix require a postfix init script inside init script repositories, commonly /etc/init.d.

chkconfig and update-rc.d (debian) just manipule scripts in /etc/rc#.d/, where # is the startup runrelevel that the default is set on /etc/inittab on line with initdefault term. Im my case is:

id:2:initdefault:

Then the symbolics links on /etc/rc2.d/ will be called. The name of this links have a pattern [S|K]\d{1,}dstname, e.g:

$ ls -l /etc/rc2.d/ | grep postfix
lrwxrwxrwx 1 root root  17 Ago 16 09:04 S22postfix -> ../init.d/postfix

S means /etc/init.d/postfix start K means /etc/init.d/postfix stop

22 is the links execution order.

Then you need check inittab to get default run level (initdefault), check the links on /etc/rcX.d (X is initdefault value), and have the link with a postfix startup script as target ( a script that supportstartfor S prefix links andstop` for K prefix links args).

This is how initsysv system works, but each distro can change a little.