|
ru.unix.bsd- RU.UNIX.BSD ------------------------------------------------------------------ From : Valentin Davydov 2:5020/400 21 Jun 2005 12:15:19 To : Alex Ivanov Subject : Re: PID процесса в sh скрипте -------------------------------------------------------------------------------- > From: "Alex Ivanov" <orm@ridexgroup.ru> > Date: Tue, 21 Jun 2005 06:49:37 +0000 (UTC) > >Есть такая конструкция в sh скрипте: >urlsnarf -i fxp >> /path/to/log/log.txt & >echo $! > /path/to/pid/urlsnarf.fxp0.pid > >Решил переделать все по умному и выводить все в syslog, т.е >urlsnarf -i fxp |logger -t urlsnarf & >echo $! > /path/to/pid/urlsnarf.fxp0.pid > >И тут вылезло, что в urlsnarf.fxp0.pid остается pid процесса logger, а не >urlsnarf. Есть решение, как обойти? Во-первых, надо ли обходить? Ведь urlsnarf и logger связаны пайпом, так что при помирании одного из них другой получит SIGPIPE и тоже сдохнет. А в-главных, man sh: Background Commands (&) If a command is terminated by the control operator ampersand (&), the shell executes the command asynchronously; the shell does not wait for the command to finish before executing the next command. The format for running a command in background is: command1 & [command2 & ...] То есть в твоём случае это будет что-то вроде (urlsnarf -i fxp & echo $! > /var/run/urlsnarf.fxp.pid) | logger -t urlsnarf & Вал. Дав. --- ifmail v.2.15dev5.3 * Origin: Demos online service (2:5020/400) Вернуться к списку тем, сортированных по: возрастание даты уменьшение даты тема автор
Архивное /ru.unix.bsd/657700d29ebe.html, оценка из 5, голосов 10
|