Likely the environment is different when running under cron.
Try qualifying the exact path(s)
/usr/bin/nc -dl 12.34.56.78 1234 > /absolute/path/to/my/file & echo $!
Also note that there are two "competing" popular versions of netcat:
- netcat-traditional
- netcat-openbsd
with slightly different command line options
Also, consider just making things a loop:
#!/bin/sh
exec < /dev/null > /dev/null
while true
do
nc -dl 12.34.56.78 1234
done