When I do
node process.js 1>$LOGFOLDER\\$$.log
the created process's PID become the filename. I want to run this process in the background as I want to run many instances of the same process.js. So, I added & at the end,
node process.js 1>$LOGFOLDER\\$$.log &
This made the process to run in the background but the PID(the filename) is always wrong. I did log the process id using $! after the above line. In first case both $!'s output and logfile's name are same. But in second case they are not. Making the process to run in background using & is giving different PID in the $$ placeholder. Why is this happening and how can I make the both work