Как узнать, кто (какой процесс) запускает другой процесс?

4702
David Coch

Поэтому независимо от того, сколько раз я убиваю exim4, он сразу же возвращается к жизни. Я остановил службу, и все, кроме чего-то, возвращает ее к жизни и использует для рассылки спама.

Как мне найти, кто является виновником, другими словами, кто запускает exim-процесс?

$ ps -ef | grep exim root 3038 1 0 14:48 ? 00:00:00 /usr/sbin/exim4 -Mc 1YR5Mf-0000mt-L7 107 3042 3038 0 14:48 ? 00:00:00 /usr/sbin/exim4 -Mc 1YR5Mf-0000mt-L7 root 5083 1 0 14:49 ? 00:00:00 /usr/sbin/exim4 -Mc 1YR5N0-0001Jr-88 107 5233 5083 0 14:49 ? 00:00:00 /usr/sbin/exim4 -Mc 1YR5N0-0001Jr-88 root 7420 1 0 14:49 ? 00:00:00 /usr/sbin/exim4 -Mc 1YR5NR-0001vb-Km 107 7430 7420 0 14:49 ? 00:00:00 /usr/sbin/exim4 -Mc 1YR5NR-0001vb-Km root 7454 1 0 14:49 ? 00:00:00 /usr/sbin/exim4 -Mc 1YR5NR-0001wA-Rl 107 7478 7454 0 14:49 ? 00:00:00 /usr/sbin/exim4 -Mc 1YR5NR-0001wA-Rl root 7518 1 0 14:49 ? 00:00:00 /usr/sbin/exim4 -Mc 1YR5NS-0001xF-8C 107 7523 7518 0 14:49 ? 00:00:00 /usr/sbin/exim4 -Mc 1YR5NS-0001xF-8C root 8863 1 0 14:50 ? 00:00:00 /usr/sbin/exim4 -Mc 1YR5Nm-0002Ir-93 107 8866 8863 0 14:50 ? 00:00:00 /usr/sbin/exim4 -Mc 1YR5Nm-0002Ir-93 root 8876 1 0 14:50 ? 00:00:00 /usr/sbin/exim4 -Mc 1YR5Nm-0002J5-Ee 
4
Вы можете попробовать ограничить исполняемый файл exim (убрать выполнение), а затем проверить dmesg, чтобы увидеть, какое приложение жалуется на это. Frank Thomas 9 лет назад 0
Это отличная идея, Фрэнк. Как мне хвост dmesg? David Coch 9 лет назад 0
зависит от вашей системы, но от моего Debian, его `sudo tail / var / log / dmesg`. в Ubuntu вы можете просто сказать `tail dmesg`. и не забудьте проверить другие журналы. также. журнал отладки может не получать уведомления об этом сбое, но, надеюсь, sys или сообщения получат. Frank Thomas 9 лет назад 0
Я нахожусь на UBUNTU. Проверяем `/ var / log / dmesg` и` / var / log / syslog`, но там ничего не видим. Вы уверены, что эта ошибка разрешения появляется там? David Coch 9 лет назад 0
как я уже сказал, не всегда. Разработчик должен решить, писать ли отладочные сообщения. вместо этого проверьте журналы sys / messages / auth и посмотрите, что вы видите. Frank Thomas 9 лет назад 0

1 ответ на вопрос

6
agtoever

A direct answer to your question (but not your problem) would be: ps -axjf. That's a and x to see "all" processes (see man page for a more elaborate explanation of these parameters), j for jobs format and f for the fancy ASCII art tree. The ppid (first column) shows the parent process ID.

A more direct approach to check the PPid of a specific process would be to check the PPid in /proc/<processid>/status, like this: grep PPid /proc/2774/status.

Now let's focus on your problem. With the information you provided, my guess is that you're trying to kill one of the mail delivery processes (in most configurations, exim spawns a separate process for each message to be delivered under user root). These processes use the -Mc option. From the Exim manual:

-MC <transport> <hostname> <sequence number> <message id>

This option is not intended for use by external callers. It is used internally by Exim to invoke another instance of itself to deliver a waiting message using an existing SMTP connection, which is passed as the standard input. This must be the final option, and the caller must be root or the Exim user in order to use it.

There is a queue runner process (often found in ps like: /usr/local/exim-in/bin/exim -bd -q 10m under user mail; not root). Probably that's the parent process. Note that exim often has more than one queue runner process. To inspect what's going on - process-wise - you can use the ps command mentioned earlier.

You might want to check what messages are queuing up in your mail queue (and why).

Похожие вопросы