4

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?

1
  • For those who landed on this page and didn't build/install postfix, on centOS I've used "systemctl enable postfix" followed by "systemctl start postfix" but this only works because postfix was installed by default Oct 18, 2022 at 20:01

4 Answers 4

5

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.

2
  • Thanks for a complete answer here, I will try it out tomorrow.
    – enfield
    Jan 18, 2012 at 3:31
  • Ubuntu users could use: sudo update-rc.d postfix enable
    – Farahmand
    Jul 12, 2015 at 12:05
0

The postfix distribution does not come with a sample initscript, but you can simply use the provided "postfix" wrapper program, which is the master control program for postfix.

Just include postfix start anywhere in the boot sequence - rc.local is often a good place for this.

See http://www.postfix.org/PACKAGE_README.html for more details.

4
  • Starting an MTA from rc.local - yeuch!
    – symcbean
    Jan 16, 2012 at 9:26
  • And what makes your init script so super superior ?
    – adaptr
    Jan 16, 2012 at 17:03
  • @adaptr You're kidding, right? How are you going to make sure that Postfix shuts down cleanly when you reboot the machine?
    – Magellan
    Jan 16, 2012 at 19:22
  • I'm not saying an init script should not be used. I said his specific solution is nonsense.
    – adaptr
    Jan 17, 2012 at 11:57
0

I'm very interested why you need to build Postfix from sources. In only very few cases this is worth the trouble. The recommended way is to use the pre-compiled version provided by your distribution. Why? Because you don't have to care about security fixes. Additionally you get the comfort of init scripts and the like. Plus a guarantee that there are no problems combining Postfix with related software from your distribution.

If you now say "but the speed improvement by self-compiling!" then I have to say "is nothing to care about". "But I have to care about every CPU cycle!" Then use a distribution like Gentoo with all the positive aspects from above plus tuning at every screw.

1
  • I built Postfix from the sources so I could include the packages I needed to wrap in. Unfortunately with the rpms used on the server any pre-compilied version would not even install properly / start working. Hence going to a new compile and now I have it working as it should. Of course minus the problems with automation. I am all for using something if it works, I do not just create work for the fun of it.
    – enfield
    Jan 18, 2012 at 3:34
-2

Your postfix distro probably came with a start/stop script - indeed the recommendation to use 'postfix start' in section 9 of the document you read implies this is running the start/stop script directly not the binary.

You've not mentioned what Linux distro you're using. Traditionally, Linux uses the SysV init layout, but more recently more distro's are moving to upstart however since the latter is usually set up to be backward compatible with SysV, then it's probably simpler to use that model if you're installing your own postfix from tarball rather than using the package manager.

If you can't find an init script in your tarball then there's lots of examples on the internet e.g. this one. Just add it in your init scripts dir and create appropriately named symlinks in the runlevel dirs as described in the article linked above (or use chkconfig if your system supports it).

1
  • He indicated postfix was built from source, ergo there is no init script. Also, there are no generic init scripts that work for just any distro.
    – adaptr
    Jan 16, 2012 at 17:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .