I have some processes showing up as <defunct>
in top
(and ps
). I've boiled things down from the real scripts and programs.
In my crontab
:
* * * * * /tmp/launcher.sh /tmp/tester.sh
The contents of launcher.sh
(which is of course marked executable):
#!/bin/bash
# the real script does a little argument processing here
"$@"
The contents of tester.sh
(which is of course marked executable):
#!/bin/bash
sleep 27 & # the real script launches a compiled C program in the background
ps
shows the following:
user 24257 24256 0 18:32 ? 00:00:00 [launcher.sh] <defunct>
user 24259 1 0 18:32 ? 00:00:00 sleep 27
Note that tester.sh
does not appear--it has exited after launching the background job.
Why does launcher.sh
stick around, marked <defunct>
? It only seems to do this when launched by cron
--not when I run it myself.
Additional note: launcher.sh
is a common script in the system this runs on, which is not easily modified. The other things (crontab
, tester.sh
, even the program that I run instead of sleep
) can be modiified much more easily.