I have a bash script that needs to be executed with nohup due to its long execution time. How can I verify if the script is currently running with nohup, or if there are alternative methods to ensure this?
I am considering automatically restarting the script with nohup, but I'm concerned if this could cause any issues, especially if it was initially launched with nohup.
I've tried to identify the process using the PID with the commands "ls -l /proc/[PID]/fd" and "ps aux". Unfortunately, these commands do not clearly show whether nohup was used. They merely indicate that the output is being redirected from the terminal to a different location. In addition, while the 'jobs -l' command shows that the script is running with nohup from the terminal, I'm unable to verify this within the script itself because the script runs in its own shell so lacks the necessary access to the jobs of the parent shell
nohupto run the script or run it in the background or whatever should be the responsibility of whomever or whatever launches the script, not of the script itself.ppidand see if your parent isnohup.