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

I wrote a small init script for proftpd (latest stable version, compiled myself) and am noticing that the executable exits with status 0 even if server fails to start (in my case, for example, due to SSH port conflict).

  1. Shouldn’t it exit with > 0? Or,
  2. How can a script detect whether startup was successful short of sleeping for arbitrary time and checking for PID?
# ./proftpd
# echo $? //returns 0

…but in /var/log/messages:

Jan 27 12:20:15 staging3 proftpd[9103]: - Failed binding to, port 22: Address already in use Jan 27 12:20:15 staging3 proftpd[9103]: - Check the ServerType directive to ensure you are configured correctly.

Thanks -nikita

share|improve this question

1 Answer 1

As you suggest, if you can't rely one the return code, you have to check the PID (or to check if the port 22 is in use, or whatever other trick).

./proftpd &
echo 'the PID is ' $!
share|improve this answer
specific to ProFTPD, is it OK to check for pid as soon as ./proftp call returns, or do I have to sleep for an arbitrary amt of time? in other words, if proftpd is started successfully, is PID guaranteed to exist by the time proftpd exits? –  Nikita Jan 27 '12 at 21:50

Your Answer


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.