How to execute a shell script using nohup?

To execute a shell script using the nohup command, follow these steps:

  1. Open the terminal or command prompt.
  2. Run your_script.sh in the background using nohup.
  3. the script you have named “your_script.sh”
  4. Press the enter key to execute the command.
  5. The output file for the nohup command.

Important points to note:

  1. Please make sure you have granted executable permissions before running the script, you can use the command chmod +x your_script.sh to grant execution permission.
  2. To specify a different path and name for the output file while running your script without generating a nohup.out file in the current directory, you can use the following command: nohup sh your_script.sh > /path/to/output.log &

    Here, /path/to/output.log represents the desired file path and name where you want to save the output.

  3. To view the output of the script in real time, you can use the command “tail -f nohup.out” to monitor the contents of the nohup.out file.
bannerAds