I would like to start a background process from bash script, but at the same time give it another name and also make it immune to CTRL-C. I tried the following:
exec -a NiceName java -cp ....long java command line & tail -f logs/the.log
I want the
exec to provide the process another name than just
I want to start it in the background to be able to immediately run tail on the logs of the process to verify the startup.
This works until I hit CTRL-C to stop the script/tail because the SIGINT is passed to the
java process which terminates too.
I also tried combinations of
(exec ...&) and
(exec ...)&. What does work is
exec bash -c "java command line escaping hell&" tail -f logs/the.log
but I would hope there is way without escaping hell. I also tried things with
disown to no avail.
If I remove the
exec, the sub-process is immune to CTRL-C, but then I cannot give it a name.