NcFTPd : FAQ : System Administration notes for NcFTPd versions up to 2.6.3

 

How do I shutdown NcFTPd?  I'm running version 2.6.3 or earlier.

Short answer: Run the pid-file script, which is named /var/run/ncftpd.pid.sh (or whatever you specified for the pid-file option in your NcFTPd general.cf file).

Long answer: To shutdown NcFTPd, you send the “main” NcFTPd process a termination signal.  NcFTPd has one child process which is responsible for managing all of the subprocesses, so to do a proper shutdown you find the process ID of the main process and “kill –TERM” (or equivalently, “kill –15”) that PID.

To find which process is the “main” NcFTPd process, you have a few options.  First, you specify a PID file in the NcFTPd general.cf file, under the pid-file option.  When NcFTPd is running, it maintains a list of process IDs in this file.  But instead of being just a list of process ID numbers, you’ll notice that it is actually formatted so you can run it as a shell script.  Here is a snippet from a sample ncftpd.pid.sh file looks like:

$ head -5 /var/run/ncftpd.pid.sh
#!/bin/sh
kill -15    856                # main process
sleep 5
kill -9     865 2>/dev/null    # logd
kill -9   32096 2>/dev/null    # child 1   

The script is written so that it sends a termination signal to the main process, and gives it a few seconds to gracefully shutdown the rest of the processes.  After 5 seconds, the script forcefully terminates any remaning processes.

Another way to determine the main process is to use the ps program to list all of the ncftpd processes.  The main process is the parent of all the other ncftpd processes, so use the “PPID” (parent process ID) field of ps to see which PID is the parent process.  Example, using the Linux version of ps:

$ ps alx | sed -n '1,1p;/ncftpd/p'
  F   UID   PID  PPID PRI  NI   VSZ  RSS WCHAN  STAT TTY        TIME COMMAND
100     0   856     1   0   0  1852 1180 nanosl S    ?          1:15 ncftpd -v g…
140     0   865   856   1   1  1664  396 pipe_r SN   ?          0:00 ncftpd -v g…
140     0 32096   856   0   0  1880 1292 wait_f S    ?          0:00 ncftpd -v g…

Here you can see that there are two child processes, whose parent process ID is 856, so you can do a “kill –TERM 856” to shutdown.

Note that you’ll need to use the proper syntax for your platform’s version of ps to get the PPID field to display.  On many systems, “ps alx” will work, and on others, you could try “ps –ef”.  Consult the manual page for ps for details.

How do I restart NcFTPd?  I'm running version 2.6.3 or earlier.

If you followed the installation instructions, then NcFTPd is running from the /etc/inittab.  That means to do a restart, all you need to do is terminate all of the processes currently running.  Since NcFTPd is specified as “respawn” in the /etc/inittab, the “init” process will immediately start up a new instance when it notices the previous instance exited.

See “How do I shutdown NcFTPd” on how you should properly kill all the currently running processes.

How do I shutdown NcFTPd and not have it start up again automatically?

If you are running NcFTPd from the /etc/inittab, then edit that file and comment out (or delete) the line that pertains to NcFTPd.  Then shutdown NcFTPd.

If you are not using the /etc/inittab, then if NcFTPd is respawning when you kill it then you may be using the utility program “respawn” that comes with the NcFTPd package in the extra directory.  You’ll have to kill the running “respawn” process and then shutdown NcFTPd.  You might also want to disable running “respawn” at startup until you’ve finished maintenance.

How do I “tickle” NcFTPd so it reloads it’s configuration files?

Currently NcFTPd cannot reload the general.cf, so if you modify it, you need to do a full restart.  But you can have it reload the domain.cf, and to do that, you send the main NcFTPd process a hangup signal (SIGHUP) using “kill –HUP” (or kill –1).  See the section on how to shutdown NcFTPd for how you can find out which process is the “main” process.

 

Up
 NcFTPd Home